summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorScott Boggs <scott@tams.tech>2023-09-03 06:07:24 -0400
committerGitHub <noreply@github.com>2023-09-03 06:07:24 -0400
commita8e493ebc4d73efa8113b6b4dfd83128d8a0f3b7 (patch)
tree12fb14ed66a51c9b60685d03c4112ebb02534d6f
parent1efc96b9664b44b121cba32e55494fea706af609 (diff)
parentec1f7c501fb98920d7f31a57447ce9504949adf6 (diff)
Merge pull request #115 from dscottboggs/fix/misc
Fix: misc
-rw-r--r--.github/workflows/rust.yml4
-rw-r--r--Cargo.toml2
-rw-r--r--entities/src/admin/canonical_email_block.rs3
-rw-r--r--entities/src/auth/scopes.rs32
-rw-r--r--examples/log_events.rs7
-rw-r--r--examples/post_status.rs2
-rw-r--r--src/errors.rs2
-rw-r--r--src/event_stream.rs2
-rw-r--r--src/helpers/cli.rs2
-rw-r--r--src/helpers/env.rs2
-rw-r--r--src/helpers/json.rs4
-rw-r--r--src/helpers/toml.rs4
-rw-r--r--src/mastodon.rs8
13 files changed, 36 insertions, 38 deletions
diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml
index e5f9399..db11e23 100644
--- a/.github/workflows/rust.yml
+++ b/.github/workflows/rust.yml
@@ -39,7 +39,7 @@ jobs:
- uses: swatinem/rust-cache@v2
- uses: dtolnay/rust-toolchain@master
with:
- toolchain: 1.65.0
+ toolchain: 1.67.0
components: clippy
- run: cargo clippy --all-features -- -D warnings
@@ -51,7 +51,7 @@ jobs:
- uses: swatinem/rust-cache@v2
- uses: dtolnay/rust-toolchain@master
with:
- toolchain: 1.65.0
+ toolchain: 1.67.0
components: rustfmt
- run: cargo fmt --check
diff --git a/Cargo.toml b/Cargo.toml
index 587413b..fee0dd4 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -11,7 +11,7 @@ version = "1.2.2"
license = "MIT/Apache-2.0"
authors = ["Aaron Power <theaaronepower@gmail.com>", "Paul Woolcock <paul@woolcock.us>", "D. Scott Boggs <scott@tams.tech>"]
edition = "2021"
-rust-version = "1.65"
+rust-version = "1.67"
[package]
name = "mastodon-async"
diff --git a/entities/src/admin/canonical_email_block.rs b/entities/src/admin/canonical_email_block.rs
index ece40e3..b79d0b5 100644
--- a/entities/src/admin/canonical_email_block.rs
+++ b/entities/src/admin/canonical_email_block.rs
@@ -15,8 +15,7 @@ pub struct CanonicalEmailBlock {
impl PartialOrd for CanonicalEmailBlock {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
- self.canonical_email_hash
- .partial_cmp(&other.canonical_email_hash)
+ Some(self.cmp(other))
}
}
impl Ord for CanonicalEmailBlock {
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/examples/post_status.rs b/examples/post_status.rs
index 7b42617..e70b92f 100644
--- a/examples/post_status.rs
+++ b/examples/post_status.rs
@@ -12,7 +12,7 @@ async fn run() -> Result<()> {
.status(register::read_line(
"Enter a status to post privately (enter to send): ",
)?)
- .visibility(Visibility::Unlisted)
+ .visibility(Visibility::Private)
.language(Language::Eng)
.build()?;
diff --git a/src/errors.rs b/src/errors.rs
index 0b68ea9..0efdad9 100644
--- a/src/errors.rs
+++ b/src/errors.rs
@@ -120,7 +120,7 @@ pub struct ApiError {
impl fmt::Display for ApiError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- write!(f, "{:?}", self)
+ write!(f, "{self:?}")
}
}
diff --git a/src/event_stream.rs b/src/event_stream.rs
index 0ff907d..4e523cf 100644
--- a/src/event_stream.rs
+++ b/src/event_stream.rs
@@ -83,6 +83,6 @@ pub(crate) fn make_event(lines: &[String]) -> Result<Event> {
Event::Delete(data)
}
"filters_changed" => Event::FiltersChanged,
- _ => return Err(Error::Other(format!("Unknown event `{}`", event))),
+ _ => return Err(Error::Other(format!("Unknown event `{event}`"))),
})
}
diff --git a/src/helpers/cli.rs b/src/helpers/cli.rs
index b48d88f..fdd1583 100644
--- a/src/helpers/cli.rs
+++ b/src/helpers/cli.rs
@@ -14,7 +14,7 @@ pub async fn authenticate(registration: Registered) -> Result<Mastodon> {
let mut stdout = stdout.lock();
let mut stdin = stdin.lock();
- writeln!(&mut stdout, "Click this link to authorize: {}", url)?;
+ writeln!(&mut stdout, "Click this link to authorize: {url}")?;
write!(&mut stdout, "Paste the returned authorization code: ")?;
stdout.flush()?;
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 {
diff --git a/src/mastodon.rs b/src/mastodon.rs
index 02ede22..fbf4330 100644
--- a/src/mastodon.rs
+++ b/src/mastodon.rs
@@ -171,7 +171,7 @@ impl Mastodon {
/// PUT /api/v1/filters/:id
pub async fn update_filter(&self, id: &str, request: &mut AddFilterRequest) -> Result<Filter> {
- let url = self.route(format!("/api/v1/filters/{}", id));
+ let url = self.route(format!("/api/v1/filters/{id}"));
let response = self.client.put(&url).json(&request).send().await?;
read_response(response).await
@@ -213,9 +213,9 @@ impl Mastodon {
pub async fn get_tagged_timeline(&self, hashtag: String, local: bool) -> Result<Vec<Status>> {
let base = "/api/v1/timelines/tag/";
let url = if local {
- self.route(format!("{}{}?local=1", base, hashtag))
+ self.route(format!("{base}{hashtag}?local=1"))
} else {
- self.route(format!("{}{}", base, hashtag))
+ self.route(format!("{base}{hashtag}"))
};
self.get(url).await
@@ -251,7 +251,7 @@ impl Mastodon {
request: StatusesRequest<'a>,
) -> Result<Page<Status>> {
let call_id = Uuid::new_v4();
- let mut url = format!("{}/api/v1/accounts/{}/statuses", self.data.base, id);
+ let mut url = format!("{}/api/v1/accounts/{id}/statuses", self.data.base);
url += request.to_query_string()?.as_str();