Skip to content

Commit 43dc365

Browse files
committed
Enable nursery lints in other crates
1 parent 761e3c5 commit 43dc365

File tree

8 files changed

+33
-33
lines changed

8 files changed

+33
-33
lines changed

database/src/database.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ fn validate_message(message: &NewMessage) -> Result<()> {
1414
Ok(())
1515
}
1616

17-
#[derive(Debug, Deserialize, PartialEq, Serialize)]
17+
#[derive(Debug, Deserialize, Eq, PartialEq, Serialize)]
1818
pub struct MailboxInfo {
1919
pub name: Mailbox,
2020
pub message_count: usize,
@@ -28,7 +28,7 @@ impl<B: Backend + Sized> Database<B> {
2828
// Create a new Database that uses the provided backend
2929
#[must_use]
3030
pub fn new(backend: B) -> Self {
31-
Database { backend }
31+
Self { backend }
3232
}
3333

3434
// Add multiple new messages, returning the new messages

database/src/filter.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ pub struct Filter {
7575
impl Filter {
7676
// Create a new message filter
7777
pub fn new() -> Self {
78-
Filter::default()
78+
Self::default()
7979
}
8080

8181
// Add a mailbox filter
@@ -114,14 +114,10 @@ impl Filter {
114114
.add(Expr::col(MessageIden::Mailbox).like(format!("{mailbox}/%")))
115115
.add(Expr::col(MessageIden::Mailbox).eq(mailbox))
116116
}))
117-
.add_option(self.states.map(|states| {
118-
Expr::col(MessageIden::State).is_in(
119-
states
120-
.iter()
121-
.map(|state| (*state).into())
122-
.collect::<Vec<u32>>(),
123-
)
124-
}))
117+
.add_option(
118+
self.states
119+
.map(|states| Expr::col(MessageIden::State).is_in(states.iter().copied())),
120+
)
125121
}
126122

127123
// Determine whether a message filter is unrestricted and matches all messages

database/src/http_backend.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ impl HttpBackend {
2525
.context("Invalid authorization token")?,
2626
);
2727
}
28-
Ok(HttpBackend {
28+
Ok(Self {
2929
client: Client::builder()
3030
.default_headers(headers)
3131
.build()

database/src/lib.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
#![deny(clippy::pedantic)]
2-
#![allow(clippy::missing_errors_doc)]
1+
#![warn(clippy::pedantic, clippy::nursery)]
2+
#![allow(
3+
clippy::future_not_send,
4+
clippy::missing_const_for_fn,
5+
clippy::missing_errors_doc
6+
)]
37

48
mod backend;
59
mod database;

database/src/mailbox.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ pub struct Mailbox(String);
1010
impl Mailbox {
1111
// Iterate over the mailbox's ancestor mailboxes, including itself
1212
// Mailbox "a/b/c" with produce "a", "a/b", "a/b/c"
13-
pub fn iter_ancestors(&self) -> impl Iterator<Item = Mailbox> + '_ {
13+
pub fn iter_ancestors(&self) -> impl Iterator<Item = Self> + '_ {
1414
let sections = self.0.split('/').collect::<Vec<_>>();
15-
(0..sections.len()).map(move |index| Mailbox(sections[0..=index].join("/")))
15+
(0..sections.len()).map(move |index| Self(sections[0..=index].join("/")))
1616
}
1717

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

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

8989
impl From<Mailbox> for Value {
90-
fn from(value: Mailbox) -> Value {
91-
Value::String(Some(Box::new(value.0)))
90+
fn from(value: Mailbox) -> Self {
91+
Self::String(Some(Box::new(value.0)))
9292
}
9393
}
9494

database/src/message.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ pub enum State {
1616
impl Display for State {
1717
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
1818
f.write_str(match self {
19-
State::Unread => "unread",
20-
State::Read => "read",
21-
State::Archived => "archived",
19+
Self::Unread => "unread",
20+
Self::Read => "read",
21+
Self::Archived => "archived",
2222
})
2323
}
2424
}
@@ -28,9 +28,9 @@ impl TryFrom<u32> for State {
2828

2929
fn try_from(value: u32) -> anyhow::Result<Self> {
3030
match value {
31-
0 => Ok(State::Unread),
32-
1 => Ok(State::Read),
33-
2 => Ok(State::Archived),
31+
0 => Ok(Self::Unread),
32+
1 => Ok(Self::Read),
33+
2 => Ok(Self::Archived),
3434
_ => Err(anyhow!("Invalid message state {}", value)),
3535
}
3636
}
@@ -41,9 +41,9 @@ impl FromStr for State {
4141

4242
fn from_str(value: &str) -> Result<Self, Self::Err> {
4343
match value {
44-
"unread" => Ok(State::Unread),
45-
"read" => Ok(State::Read),
46-
"archived" => Ok(State::Archived),
44+
"unread" => Ok(Self::Unread),
45+
"read" => Ok(Self::Read),
46+
"archived" => Ok(Self::Archived),
4747
_ => Err(anyhow!("Invalid message state {}", value)),
4848
}
4949
}
@@ -60,8 +60,8 @@ impl From<State> for u32 {
6060
}
6161

6262
impl From<State> for Value {
63-
fn from(value: State) -> Value {
64-
Value::Unsigned(Some(value.into()))
63+
fn from(value: State) -> Self {
64+
Self::Unsigned(Some(value.into()))
6565
}
6666
}
6767

database/src/sqlite_backend.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ impl SqliteBackend {
3232
let pool = SqlitePool::connect_with(options)
3333
.await
3434
.context("Failed to open database")?;
35-
let backend = SqliteBackend { pool };
35+
let backend = Self { pool };
3636
backend.init().await?;
3737
Ok(backend)
3838
}
@@ -63,7 +63,7 @@ impl SqliteBackend {
6363
let pool = SqlitePool::connect_with(options)
6464
.await
6565
.context("Failed to open database")?;
66-
let backend = SqliteBackend { pool };
66+
let backend = Self { pool };
6767

6868
// Reset the database
6969
let sql = Table::drop()

server/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![deny(clippy::pedantic)]
1+
#![warn(clippy::pedantic, clippy::nursery)]
22

33
mod cli;
44

0 commit comments

Comments
 (0)