Skip to content

Commit

Permalink
Enable nursery lints in other crates
Browse files Browse the repository at this point in the history
  • Loading branch information
canac committed Nov 3, 2024
1 parent 761e3c5 commit 43dc365
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 33 deletions.
4 changes: 2 additions & 2 deletions database/src/database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ fn validate_message(message: &NewMessage) -> Result<()> {
Ok(())
}

#[derive(Debug, Deserialize, PartialEq, Serialize)]
#[derive(Debug, Deserialize, Eq, PartialEq, Serialize)]
pub struct MailboxInfo {
pub name: Mailbox,
pub message_count: usize,
Expand All @@ -28,7 +28,7 @@ impl<B: Backend + Sized> Database<B> {
// Create a new Database that uses the provided backend
#[must_use]
pub fn new(backend: B) -> Self {
Database { backend }
Self { backend }
}

// Add multiple new messages, returning the new messages
Expand Down
14 changes: 5 additions & 9 deletions database/src/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ pub struct Filter {
impl Filter {
// Create a new message filter
pub fn new() -> Self {
Filter::default()
Self::default()
}

// Add a mailbox filter
Expand Down Expand Up @@ -114,14 +114,10 @@ impl Filter {
.add(Expr::col(MessageIden::Mailbox).like(format!("{mailbox}/%")))
.add(Expr::col(MessageIden::Mailbox).eq(mailbox))
}))
.add_option(self.states.map(|states| {
Expr::col(MessageIden::State).is_in(
states
.iter()
.map(|state| (*state).into())
.collect::<Vec<u32>>(),
)
}))
.add_option(
self.states
.map(|states| Expr::col(MessageIden::State).is_in(states.iter().copied())),
)
}

// Determine whether a message filter is unrestricted and matches all messages
Expand Down
2 changes: 1 addition & 1 deletion database/src/http_backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ impl HttpBackend {
.context("Invalid authorization token")?,
);
}
Ok(HttpBackend {
Ok(Self {
client: Client::builder()
.default_headers(headers)
.build()
Expand Down
8 changes: 6 additions & 2 deletions database/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#![deny(clippy::pedantic)]
#![allow(clippy::missing_errors_doc)]
#![warn(clippy::pedantic, clippy::nursery)]
#![allow(
clippy::future_not_send,
clippy::missing_const_for_fn,
clippy::missing_errors_doc
)]

mod backend;
mod database;
Expand Down
10 changes: 5 additions & 5 deletions database/src/mailbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ pub struct Mailbox(String);
impl Mailbox {
// Iterate over the mailbox's ancestor mailboxes, including itself
// Mailbox "a/b/c" with produce "a", "a/b", "a/b/c"
pub fn iter_ancestors(&self) -> impl Iterator<Item = Mailbox> + '_ {
pub fn iter_ancestors(&self) -> impl Iterator<Item = Self> + '_ {
let sections = self.0.split('/').collect::<Vec<_>>();
(0..sections.len()).map(move |index| Mailbox(sections[0..=index].join("/")))
(0..sections.len()).map(move |index| Self(sections[0..=index].join("/")))
}

// Return the name of the mailbox without its ancestors
Expand All @@ -23,7 +23,7 @@ impl Mailbox {

// Return true if the mailbox is an ancestor of the other mailbox
#[must_use]
pub fn is_ancestor_of(&self, other: &Mailbox) -> bool {
pub fn is_ancestor_of(&self, other: &Self) -> bool {
other.0.starts_with(&format!("{}/", self.0))
}
}
Expand Down Expand Up @@ -87,8 +87,8 @@ impl From<Mailbox> for String {
}

impl From<Mailbox> for Value {
fn from(value: Mailbox) -> Value {
Value::String(Some(Box::new(value.0)))
fn from(value: Mailbox) -> Self {
Self::String(Some(Box::new(value.0)))
}
}

Expand Down
22 changes: 11 additions & 11 deletions database/src/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ pub enum State {
impl Display for State {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
f.write_str(match self {
State::Unread => "unread",
State::Read => "read",
State::Archived => "archived",
Self::Unread => "unread",
Self::Read => "read",
Self::Archived => "archived",
})
}
}
Expand All @@ -28,9 +28,9 @@ impl TryFrom<u32> for State {

fn try_from(value: u32) -> anyhow::Result<Self> {
match value {
0 => Ok(State::Unread),
1 => Ok(State::Read),
2 => Ok(State::Archived),
0 => Ok(Self::Unread),
1 => Ok(Self::Read),
2 => Ok(Self::Archived),
_ => Err(anyhow!("Invalid message state {}", value)),
}
}
Expand All @@ -41,9 +41,9 @@ impl FromStr for State {

fn from_str(value: &str) -> Result<Self, Self::Err> {
match value {
"unread" => Ok(State::Unread),
"read" => Ok(State::Read),
"archived" => Ok(State::Archived),
"unread" => Ok(Self::Unread),
"read" => Ok(Self::Read),
"archived" => Ok(Self::Archived),
_ => Err(anyhow!("Invalid message state {}", value)),
}
}
Expand All @@ -60,8 +60,8 @@ impl From<State> for u32 {
}

impl From<State> for Value {
fn from(value: State) -> Value {
Value::Unsigned(Some(value.into()))
fn from(value: State) -> Self {
Self::Unsigned(Some(value.into()))
}
}

Expand Down
4 changes: 2 additions & 2 deletions database/src/sqlite_backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ impl SqliteBackend {
let pool = SqlitePool::connect_with(options)
.await
.context("Failed to open database")?;
let backend = SqliteBackend { pool };
let backend = Self { pool };
backend.init().await?;
Ok(backend)
}
Expand Down Expand Up @@ -63,7 +63,7 @@ impl SqliteBackend {
let pool = SqlitePool::connect_with(options)
.await
.context("Failed to open database")?;
let backend = SqliteBackend { pool };
let backend = Self { pool };

// Reset the database
let sql = Table::drop()
Expand Down
2 changes: 1 addition & 1 deletion server/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![deny(clippy::pedantic)]
#![warn(clippy::pedantic, clippy::nursery)]

mod cli;

Expand Down

0 comments on commit 43dc365

Please sign in to comment.