Skip to content

Commit 14c8336

Browse files
committed
chore: fix Rust 1.90 clippy
1 parent f51dbc7 commit 14c8336

5 files changed

Lines changed: 16 additions & 16 deletions

File tree

src/bgp/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ impl<S: AsyncRead + AsyncWrite + Unpin> State<S> {
260260
}
261261

262262
impl State<BufReader<TcpStream>> {
263-
pub fn view(&self) -> StateView {
263+
pub fn view(&self) -> StateView<'_> {
264264
match self {
265265
Idle => StateView::Idle,
266266
Connect => StateView::Connect,

src/bgp/msg.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ impl UpdateMessage<'static> {
547547
}
548548

549549
Some(PathAttr::Communities) => {
550-
if len % 4 == 0 {
550+
if len.is_multiple_of(4) {
551551
let mut opt_buf = vec![0; len.into()];
552552
pattrs_reader.read_exact(&mut opt_buf).await?;
553553
result.route_info.comm = opt_buf
@@ -561,7 +561,7 @@ impl UpdateMessage<'static> {
561561
}
562562

563563
Some(PathAttr::ExtCommunities) => {
564-
if len % 8 == 0 {
564+
if len.is_multiple_of(8) {
565565
let mut opt_buf = vec![0; len.into()];
566566
pattrs_reader.read_exact(&mut opt_buf).await?;
567567
result.route_info.ext_comm = opt_buf
@@ -575,7 +575,7 @@ impl UpdateMessage<'static> {
575575
}
576576

577577
Some(PathAttr::Ipv6ExtCommunities) => {
578-
if len % 20 == 0 {
578+
if len.is_multiple_of(20) {
579579
let mut opt_buf = vec![0; len.into()];
580580
pattrs_reader.read_exact(&mut opt_buf).await?;
581581
if let Some(comm) = opt_buf
@@ -595,7 +595,7 @@ impl UpdateMessage<'static> {
595595
}
596596

597597
Some(PathAttr::LargeCommunities) => {
598-
if len % 12 == 0 {
598+
if len.is_multiple_of(12) {
599599
let mut opt_buf = vec![0; len.into()];
600600
pattrs_reader.read_exact(&mut opt_buf).await?;
601601
result.route_info.large_comm = opt_buf

src/ipc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ impl Session<BufReader<TcpStream>> {
3838
}
3939
}
4040

41-
pub async fn get_states(path: impl AsRef<Path>, buf: &mut Vec<u8>) -> anyhow::Result<(RunArgs, StateView, Routes)> {
41+
pub async fn get_states(path: impl AsRef<Path>, buf: &mut Vec<u8>) -> anyhow::Result<(RunArgs, StateView<'_>, Routes)> {
4242
let mut stream = UnixStream::connect(path).await?;
4343
stream.read_to_end(buf).await?;
4444
let (config, buf) = postcard::take_from_bytes_cobs(buf)?;

src/kernel/linux/nft.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ impl Nftables {
9696
Ok(apply_and_return_ruleset_async(n).await?)
9797
}
9898

99-
fn make_rule_handle(&self, handle: u32) -> schema::NfListObject {
99+
fn make_rule_handle(&self, handle: u32) -> schema::NfListObject<'_> {
100100
schema::NfListObject::Rule(schema::Rule {
101101
family: types::NfFamily::INet,
102102
table: self.table.clone(),
@@ -598,11 +598,11 @@ impl Ops<Numeric> {
598598
}
599599
*x = y;
600600
return true;
601-
} else if let Some(r2) = &r2 {
602-
if let Some(y) = x.clone().intersect(r2.clone()) {
603-
*x = y;
604-
return true;
605-
}
601+
} else if let Some(r2) = &r2
602+
&& let Some(y) = x.clone().intersect(r2.clone())
603+
{
604+
*x = y;
605+
return true;
606606
}
607607
false
608608
});

src/util.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ impl TruthTable {
155155
self
156156
}
157157

158-
pub fn possible_values_masked(&self) -> Cow<BTreeSet<u64>> {
158+
pub fn possible_values_masked(&self) -> Cow<'_, BTreeSet<u64>> {
159159
if self.inv {
160160
Cow::Owned(
161161
iter_masked(self.mask)
@@ -169,7 +169,7 @@ impl TruthTable {
169169
}
170170
}
171171

172-
pub fn shrink(&self, other_mask: u64) -> Cow<Self> {
172+
pub fn shrink(&self, other_mask: u64) -> Cow<'_, Self> {
173173
let mask = self.mask & other_mask;
174174
if mask == self.mask {
175175
Cow::Borrowed(self)
@@ -178,7 +178,7 @@ impl TruthTable {
178178
}
179179
}
180180

181-
pub fn expand(&self, other_mask: u64) -> Cow<Self> {
181+
pub fn expand(&self, other_mask: u64) -> Cow<'_, Self> {
182182
let mask = self.mask | other_mask;
183183
if mask == self.mask {
184184
Cow::Borrowed(self)
@@ -193,7 +193,7 @@ impl TruthTable {
193193
}
194194
}
195195

196-
fn expand_set(&self, other_mask: u64) -> Cow<BTreeSet<u64>> {
196+
fn expand_set(&self, other_mask: u64) -> Cow<'_, BTreeSet<u64>> {
197197
match self.expand(other_mask) {
198198
Cow::Borrowed(x) => Cow::Borrowed(&x.truth),
199199
Cow::Owned(x) => Cow::Owned(x.truth),

0 commit comments

Comments
 (0)