diff --git a/src/apps.rs b/src/apps.rs index ffce1d1..ab63548 100644 --- a/src/apps.rs +++ b/src/apps.rs @@ -130,7 +130,7 @@ impl<'a> TryInto for AppBuilder<'a> { type Error = Error; fn try_into(self) -> Result { - Ok(self.build()?) + self.build() } } @@ -188,19 +188,6 @@ mod tests { builder.build().expect("no client-name"); } - #[test] - fn test_app_try_into_app() { - let app = App { - client_name: "foo-test".to_string(), - redirect_uris: "http://example.com".to_string(), - scopes: Scopes::all(), - website: None, - }; - let expected = app.clone(); - let result = app.try_into().expect("Couldn't make App into App"); - assert_eq!(expected, result); - } - #[test] fn test_app_builder_try_into_app() { let mut builder = App::builder(); diff --git a/src/helpers/cli.rs b/src/helpers/cli.rs index c08dcba..c815fd0 100644 --- a/src/helpers/cli.rs +++ b/src/helpers/cli.rs @@ -20,5 +20,5 @@ pub fn authenticate(registration: Registered) -> Result { let mut input = String::new(); stdin.read_line(&mut input)?; let code = input.trim(); - Ok(registration.complete(code)?) + registration.complete(code) } diff --git a/src/lib.rs b/src/lib.rs index 381c26e..4c7fb98 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -356,11 +356,11 @@ impl MastodonClient for Mastodon { if ids.len() == 1 { url += "id="; - url += &ids[0]; + url += ids[0]; } else { for id in ids { url += "id[]="; - url += &id; + url += id; url += "&"; } url.pop(); @@ -391,13 +391,13 @@ impl MastodonClient for Mastodon { /// Get all accounts that follow the authenticated user fn follows_me(&self) -> Result> { let me = self.verify_credentials()?; - Ok(self.followers(&me.id)?) + self.followers(&me.id) } /// Get all accounts that the authenticated user follows fn followed_by_me(&self) -> Result> { let me = self.verify_credentials()?; - Ok(self.following(&me.id)?) + self.following(&me.id) } /// returns events that are relevant to the authorized user, i.e. home diff --git a/src/macros.rs b/src/macros.rs index b866339..9e07e61 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -134,7 +134,7 @@ macro_rules! route_v2 { let url = format!(concat!("/api/v2/", $url, "?{}"), &qs); - Ok(self.get(self.route(&url))?) + self.get(self.route(&url)) } } @@ -177,7 +177,7 @@ macro_rules! route { let url = format!(concat!("/api/v1/", $url, "?{}"), &qs); - Ok(self.get(self.route(&url))?) + self.get(self.route(&url)) } } diff --git a/src/mastodon_client.rs b/src/mastodon_client.rs index 87a320f..ba0521c 100644 --- a/src/mastodon_client.rs +++ b/src/mastodon_client.rs @@ -97,11 +97,11 @@ pub trait MastodonClient { unimplemented!("This method was not implemented"); } /// GET /api/v1/search - fn search<'a>(&self, q: &'a str, resolve: bool) -> Result { + fn search(&self, q: &'_ str, resolve: bool) -> Result { unimplemented!("This method was not implemented"); } /// GET /api/v2/search - fn search_v2<'a>(&self, q: &'a str, resolve: bool) -> Result { + fn search_v2(&self, q: &'_ str, resolve: bool) -> Result { unimplemented!("This method was not implemented"); } /// POST /api/v1/follows diff --git a/src/media_builder.rs b/src/media_builder.rs index 3eeb7d5..dec70b1 100644 --- a/src/media_builder.rs +++ b/src/media_builder.rs @@ -125,15 +125,15 @@ mod tests { #[test] fn test_from_file() { - let builder = MediaBuilder::from_file("/fake/file/path.png".into()); + let builder = MediaBuilder::from_file("/fake/file/path.png"); - assert_eq!(builder.filename, None); - assert_eq!(builder.mimetype, None); + assert_eq!(builder.filename, Some("path.png".to_string())); + assert_eq!(builder.mimetype, Some("image/png".to_string())); assert_eq!(builder.description, None); assert_eq!(builder.focus, None); if let MediaBuilderData::File(f) = builder.data { - assert_eq!(f, "/fake/file/path.png"); + assert_eq!(f.display().to_string().as_str(), "/fake/file/path.png"); } else { panic!("Unable to destructure MediaBuilder.data into a filepath"); } diff --git a/src/page.rs b/src/page.rs index a5efd56..ea90fcf 100644 --- a/src/page.rs +++ b/src/page.rs @@ -204,7 +204,7 @@ fn get_links(response: &Response) -> Result<(Option, Option)> { if let Some(link_header) = response.headers().get(LINK) { let link_header = link_header.to_str()?; let link_header = link_header.as_bytes(); - let link_header: Link = parsing::from_raw_str(&link_header)?; + let link_header: Link = parsing::from_raw_str(link_header)?; for value in link_header.values() { if let Some(relations) = value.rel() { if relations.contains(&RelationType::Next) { diff --git a/src/registration.rs b/src/registration.rs index 4ba2649..fb9b512 100644 --- a/src/registration.rs +++ b/src/registration.rs @@ -317,7 +317,7 @@ impl Registered { let mut builder = MastodonBuilder::new(); builder.client(self.client.clone()).data(data); - Ok(builder.build()?) + builder.build() } } diff --git a/src/requests/statuses.rs b/src/requests/statuses.rs index a546351..86228de 100644 --- a/src/requests/statuses.rs +++ b/src/requests/statuses.rs @@ -53,17 +53,17 @@ pub struct StatusesRequest<'a> { exclude_reblogs: bool, } -impl<'a> Into>> for &'a mut StatusesRequest<'a> { - fn into(self) -> Option> { +impl<'a> From<&'a mut StatusesRequest<'a>> for Option> { + fn from(req: &'a mut StatusesRequest<'a>) -> Option> { Some(StatusesRequest { - only_media: self.only_media, - exclude_replies: self.exclude_replies, - pinned: self.pinned, - max_id: self.max_id.clone(), - since_id: self.since_id.clone(), - limit: self.limit, - min_id: self.min_id.clone(), - exclude_reblogs: self.exclude_reblogs, + only_media: req.only_media, + exclude_replies: req.exclude_replies, + pinned: req.pinned, + max_id: req.max_id.clone(), + since_id: req.since_id.clone(), + limit: req.limit, + min_id: req.min_id.clone(), + exclude_reblogs: req.exclude_reblogs, }) } } diff --git a/src/scopes.rs b/src/scopes.rs index bd14967..ea381a9 100644 --- a/src/scopes.rs +++ b/src/scopes.rs @@ -35,7 +35,7 @@ impl FromStr for Scopes { fn from_str(s: &str) -> Result { let mut set = HashSet::new(); for scope in s.split_whitespace() { - let scope = Scope::from_str(&scope)?; + let scope = Scope::from_str(scope)?; set.insert(scope); } Ok(Scopes { scopes: set }) @@ -792,7 +792,7 @@ mod tests { ("push", Scope::Push), ]; for (source, expected) in &tests { - let result = Scope::from_str(source).expect(&format!("Couldn't parse '{}'", &source)); + let result = Scope::from_str(source).unwrap_or_else(|_| panic!("Couldn't parse '{}'", &source)); assert_eq!(result, *expected); } }