From 1057e58343b64cd621b71d202c8cc36fd5bd80bc Mon Sep 17 00:00:00 2001 From: Paul Woolcock Date: Mon, 27 Aug 2018 10:28:39 -0400 Subject: [PATCH] There's no reason for Registration::complete to take an owned string --- README.md | 2 +- examples/register.rs | 2 +- src/lib.rs | 2 +- src/registration.rs | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 28c2843..f25c9f4 100644 --- a/README.md +++ b/README.md @@ -68,7 +68,7 @@ fn register() -> Result> { io::stdin().read_line(&mut input)?; let code = input.trim().to_string(); - let mastodon = registration.complete(code)?; + let mastodon = registration.complete(&code)?; // Save app data for using on the next run. toml::to_file(&*mastodon, "mastodon-data.toml")?; diff --git a/examples/register.rs b/examples/register.rs index c9d961d..c413b99 100644 --- a/examples/register.rs +++ b/examples/register.rs @@ -39,7 +39,7 @@ pub fn register() -> Result> { println!("Click this link to authorize on Mastodon: {}", url); let code = read_line("Paste the returned authorization code: ")?; - let mastodon = registration.complete(code)?; + let mastodon = registration.complete(&code)?; // Save app data for using on the next run. toml::to_file(&*mastodon, "mastodon-data.toml")?; diff --git a/src/lib.rs b/src/lib.rs index d81331f..8b2da1f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -18,7 +18,7 @@ //! // Here you now need to open the url in the browser //! // And handle a the redirect url coming back with the code. //! let code = String::from("RETURNED_FROM_BROWSER"); -//! let mastodon = registration.complete(code)?; +//! let mastodon = registration.complete(&code)?; //! //! println!("{:?}", mastodon.get_home_timeline()?.initial_items); //! # Ok(()) diff --git a/src/registration.rs b/src/registration.rs index a3465c2..30f33b1 100644 --- a/src/registration.rs +++ b/src/registration.rs @@ -103,7 +103,7 @@ impl<'a, H: HttpSend> Registration<'a, H> { /// // Here you now need to open the url in the browser /// // And handle a the redirect url coming back with the code. /// let code = String::from("RETURNED_FROM_BROWSER"); - /// let mastodon = registration.complete(code)?; + /// let mastodon = registration.complete(&code)?; /// /// println!("{:?}", mastodon.get_home_timeline()?.initial_items); /// # Ok(()) @@ -144,7 +144,7 @@ impl Registered { /// Create an access token from the client id, client secret, and code /// provided by the authorisation url. - pub fn complete(self, code: String) -> Result> { + pub fn complete(self, code: &str) -> Result> { let url = format!( "{}/oauth/token?client_id={}&client_secret={}&code={}&grant_type=authorization_code&redirect_uri={}", self.base,