diff options
author | D. Scott Boggs <scott@tams.tech> | 2023-09-01 13:25:50 -0400 |
---|---|---|
committer | D. Scott Boggs <scott@tams.tech> | 2023-09-02 11:44:11 -0400 |
commit | cdd90ede088ed579d86d1386b438882ed04276b3 (patch) | |
tree | ac47c4571f9f65c9f3d6d0e7cf435578855345a9 | |
parent | 916ea19b3ed34a2f9473326e94a333989dfbcf4e (diff) |
More clippy lints
-rw-r--r-- | entities/src/auth/scopes.rs | 32 | ||||
-rw-r--r-- | examples/log_events.rs | 7 | ||||
-rw-r--r-- | src/helpers/env.rs | 2 | ||||
-rw-r--r-- | src/helpers/json.rs | 4 | ||||
-rw-r--r-- | src/helpers/toml.rs | 4 |
5 files changed, 24 insertions, 25 deletions
diff --git a/entities/src/auth/scopes.rs b/entities/src/auth/scopes.rs index 43bcf18..b5e6678 100644 --- a/entities/src/auth/scopes.rs +++ b/entities/src/auth/scopes.rs @@ -50,7 +50,7 @@ impl Serialize for Scopes { where S: Serializer, { - let repr = format!("{}", self); + let repr = format!("{self}"); serializer.serialize_str(&repr) } } @@ -88,7 +88,7 @@ impl Scopes { /// use mastodon_async_entities::prelude::*; /// /// let scope = Scopes::all(); - /// assert_eq!(&format!("{}", scope), "read write follow push"); + /// assert_eq!(&format!("{scope}"), "read write follow push"); /// ``` pub fn all() -> Scopes { Scopes::read_all() | Scopes::write_all() | Scopes::follow() | Scopes::push() @@ -100,7 +100,7 @@ impl Scopes { /// use mastodon_async_entities::prelude::*; /// /// let scope = Scopes::read_all(); - /// assert_eq!(&format!("{}", scope), "read"); + /// assert_eq!(&format!("{scope}"), "read"); /// ``` pub fn read_all() -> Scopes { Scopes::_read(None) @@ -112,7 +112,7 @@ impl Scopes { /// use mastodon_async_entities::auth::scopes::{Read, Scopes}; /// /// let scope = Scopes::read(Read::Accounts); - /// assert_eq!(&format!("{}", scope), "read:accounts"); + /// assert_eq!(&format!("{scope}"), "read:accounts"); /// ``` pub fn read(subscope: Read) -> Scopes { Scopes::_read(Some(subscope)) @@ -124,7 +124,7 @@ impl Scopes { /// use mastodon_async_entities::prelude::*; /// /// let scope = Scopes::write_all(); - /// assert_eq!(&format!("{}", scope), "write"); + /// assert_eq!(&format!("{scope}"), "write"); /// ``` pub fn write_all() -> Scopes { Scopes::_write(None) @@ -136,7 +136,7 @@ impl Scopes { /// use mastodon_async_entities::auth::scopes::{Scopes, Write}; /// /// let scope = Scopes::write(Write::Accounts); - /// assert_eq!(&format!("{}", scope), "write:accounts"); + /// assert_eq!(&format!("{scope}"), "write:accounts"); /// ``` pub fn write(subscope: Write) -> Scopes { Scopes::_write(Some(subscope)) @@ -148,7 +148,7 @@ impl Scopes { /// use mastodon_async_entities::prelude::*; /// /// let scope = Scopes::follow(); - /// assert_eq!(&format!("{}", scope), "follow"); + /// assert_eq!(&format!("{scope}"), "follow"); /// ``` pub fn follow() -> Scopes { Scopes::new(Scope::Follow) @@ -160,7 +160,7 @@ impl Scopes { /// use mastodon_async_entities::prelude::*; /// /// let scope = Scopes::push(); - /// assert_eq!(&format!("{}", scope), "push"); + /// assert_eq!(&format!("{scope}"), "push"); /// ``` pub fn push() -> Scopes { Scopes::new(Scope::Push) @@ -343,7 +343,7 @@ impl fmt::Display for Scope { Follow => "follow", Push => "push", }; - write!(f, "{}", s) + write!(f, "{s}") } } @@ -410,8 +410,8 @@ impl PartialOrd for Read { impl Ord for Read { fn cmp(&self, other: &Read) -> Ordering { - let a = format!("{:?}", self); - let b = format!("{:?}", other); + let a = format!("{self:?}"); + let b = format!("{other:?}"); a.cmp(&b) } } @@ -495,8 +495,8 @@ impl PartialOrd for Write { impl Ord for Write { fn cmp(&self, other: &Write) -> Ordering { - let a = format!("{:?}", self); - let b = format!("{:?}", other); + let a = format!("{self:?}"); + let b = format!("{other:?}"); a.cmp(&b) } } @@ -694,7 +694,7 @@ mod tests { ]; for (a, b) in &tests { - assert_eq!(&format!("{}", a), b); + assert_eq!(&format!("{a}"), b); } } @@ -710,7 +710,7 @@ mod tests { for (a, b) in &tests { let ser = serde_json::to_string(&a).expect("Couldn't serialize Scopes"); - let expected = format!("\"{}\"", b); + let expected = format!("\"{b}\""); assert_eq!(&ser, &expected); let des: Scopes = serde_json::from_str(&ser).expect("Couldn't deserialize Scopes"); @@ -762,7 +762,7 @@ mod tests { fn test_scopes_str_round_trip() { let original = "read write follow push"; let scopes = Scopes::from_str(original).expect("Couldn't convert to Scopes"); - let result = format!("{}", scopes); + let result = format!("{scopes}"); assert_eq!(original, result); } } diff --git a/examples/log_events.rs b/examples/log_events.rs index 92e63d9..137d6e5 100644 --- a/examples/log_events.rs +++ b/examples/log_events.rs @@ -14,10 +14,9 @@ async fn run() -> Result<()> { info!("watching mastodon for events. This will run forever, press Ctrl+C to kill the program."); stream .try_for_each(|(event, _client)| async move { - match event { - // fill in how you want to handle events here. - _ => warn!(?event, "unrecognized event received"), - } + // add a "match event {}" statement here to handle the different + // kinds of events. + warn!(?event, "unrecognized event received"); Ok(()) }) .await?; diff --git a/src/helpers/env.rs b/src/helpers/env.rs index df44028..b13e5f0 100644 --- a/src/helpers/env.rs +++ b/src/helpers/env.rs @@ -50,7 +50,7 @@ mod tests { #[test] fn test_from_env_no_prefix() { - let desered = withenv(None, || from_env()).expect("Couldn't deser"); + let desered = withenv(None, from_env).expect("Couldn't deser"); assert_eq!( desered, Data { diff --git a/src/helpers/json.rs b/src/helpers/json.rs index 7bde457..ef7c6fd 100644 --- a/src/helpers/json.rs +++ b/src/helpers/json.rs @@ -79,7 +79,7 @@ mod tests { use std::{fs::OpenOptions, io::Cursor}; use tempfile::{tempdir, NamedTempFile}; - const DOC: &'static str = indoc!( + const DOC: &str = indoc!( r#" { "base": "https://example.com", @@ -108,7 +108,7 @@ mod tests { #[test] fn test_from_slice() { let doc = DOC.as_bytes(); - let desered = from_slice(&doc).expect("Couldn't deserialize Data"); + let desered = from_slice(doc).expect("Couldn't deserialize Data"); assert_eq!( desered, Data { diff --git a/src/helpers/toml.rs b/src/helpers/toml.rs index abf2415..b3f4061 100644 --- a/src/helpers/toml.rs +++ b/src/helpers/toml.rs @@ -79,7 +79,7 @@ mod tests { use std::{fs::OpenOptions, io::Cursor}; use tempfile::{tempdir, NamedTempFile}; - const DOC: &'static str = indoc!( + const DOC: &str = indoc!( r#" base = "https://example.com" client_id = "adbc01234" @@ -106,7 +106,7 @@ mod tests { #[test] fn test_from_slice() { let doc = DOC.as_bytes(); - let desered = from_slice(&doc).expect("Couldn't deserialize Data"); + let desered = from_slice(doc).expect("Couldn't deserialize Data"); assert_eq!( desered, Data { |