Skip to content

Commit 05e8fb6

Browse files
Fix clippy issues
1 parent 7e19058 commit 05e8fb6

4 files changed

Lines changed: 6 additions & 14 deletions

File tree

bgpsim-macros/src/net.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ impl Net {
441441
// check that every router has one AS number
442442
for (ident, asn) in self.nodes.iter_mut() {
443443
if asn.is_none() {
444-
*asn = self.default_asn.clone();
444+
*asn = self.default_asn;
445445
}
446446
// check if asn is still none
447447
if asn.is_none() {

bgpsim/src/network.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ impl<P: Prefix, Q, Ospf: OspfImpl> Network<P, Q, Ospf> {
244244
let asn = asn.into();
245245
let new_router = Router::new(name.into(), router_id, asn);
246246
let router_id = new_router.router_id();
247-
self.routers.insert(router_id, new_router.into());
247+
self.routers.insert(router_id, new_router);
248248
self.ospf.add_router(router_id, asn);
249249
}
250250

@@ -1297,11 +1297,6 @@ impl<'a, P: Prefix, Ospf> Iterator for RoutersInAs<'a, P, Ospf> {
12971297
type Item = &'a Router<P, Ospf>;
12981298

12991299
fn next(&mut self) -> Option<Self::Item> {
1300-
for r in self.i.by_ref() {
1301-
if r.asn() == self.asn {
1302-
return Some(r);
1303-
}
1304-
}
1305-
None
1300+
self.i.by_ref().find(|&r| r.asn() == self.asn)
13061301
}
13071302
}

bgpsim/src/ospf/local/database.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1458,9 +1458,7 @@ pub(crate) fn compute_as_external_route(
14581458
rib: &HashMap<RouterId, OspfRibEntry>,
14591459
) -> Option<OspfRibEntry> {
14601460
// only look at External-LSAs
1461-
let Some(weight) = lsa.data.external() else {
1462-
return None;
1463-
};
1461+
let weight = lsa.data.external()?;
14641462
let target = lsa.target();
14651463

14661464
// (1) If the cost specified by the LSA is LSInfinity, or if the LSA's LS age is equal
@@ -1502,9 +1500,7 @@ pub(crate) fn compute_as_external_route(
15021500
// inter-area path; if no such path exists, do nothing with the LSA and consider the
15031501
// next in the list.
15041502
// --> We don't implement that behavior
1505-
let Some(adv_rib) = rib.get(&lsa.header.router) else {
1506-
return None;
1507-
};
1503+
let adv_rib = rib.get(&lsa.header.router)?;
15081504

15091505
// (4) Let X be the cost specified by the preferred routing table entry for the
15101506
// ASBR/forwarding address, and Y the cost specified in the LSA. X is in terms of

flake.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
rustfmt
2323
rustc
2424
trunk
25+
clippy
2526
tailwindcss_3
2627
llvmPackages.bintools
2728
];

0 commit comments

Comments
 (0)