Skip to content

Commit af3a7d8

Browse files
committed
Run cargo clippy and cargo fmt
Signed-off-by: Gris Ge <[email protected]>
1 parent 1d4709a commit af3a7d8

File tree

2 files changed

+8
-24
lines changed

2 files changed

+8
-24
lines changed

src/route/header.rs

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,9 @@ impl Emitable for RouteHeader {
9898

9999
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
100100
#[non_exhaustive]
101+
#[derive(Default)]
101102
pub enum RouteProtocol {
103+
#[default]
102104
Unspec,
103105
IcmpRedirect,
104106
Kernel,
@@ -237,12 +239,6 @@ impl std::fmt::Display for RouteProtocol {
237239
}
238240
}
239241

240-
impl Default for RouteProtocol {
241-
fn default() -> Self {
242-
Self::Unspec
243-
}
244-
}
245-
246242
impl Parseable<[u8]> for RouteProtocol {
247243
fn parse(buf: &[u8]) -> Result<Self, DecodeError> {
248244
if buf.len() == 1 {
@@ -273,7 +269,9 @@ const RT_SCOPE_NOWHERE: u8 = 255;
273269

274270
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
275271
#[non_exhaustive]
272+
#[derive(Default)]
276273
pub enum RouteScope {
274+
#[default]
277275
Universe,
278276
Site,
279277
Link,
@@ -308,12 +306,6 @@ impl From<u8> for RouteScope {
308306
}
309307
}
310308

311-
impl Default for RouteScope {
312-
fn default() -> Self {
313-
Self::Universe
314-
}
315-
}
316-
317309
impl std::fmt::Display for RouteScope {
318310
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
319311
match self {
@@ -329,8 +321,10 @@ impl std::fmt::Display for RouteScope {
329321

330322
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
331323
#[non_exhaustive]
324+
#[derive(Default)]
332325
pub enum RouteType {
333326
/// Unknown
327+
#[default]
334328
Unspec,
335329
/// Gateway or direct route
336330
Unicast,
@@ -390,12 +384,6 @@ impl From<u8> for RouteType {
390384
}
391385
}
392386

393-
impl Default for RouteType {
394-
fn default() -> Self {
395-
Self::Unspec
396-
}
397-
}
398-
399387
impl From<RouteType> for u8 {
400388
fn from(v: RouteType) -> Self {
401389
match v {

src/route/preference.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@ const ICMPV6_ROUTER_PREF_INVALID: u8 = 0x2;
77

88
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
99
#[non_exhaustive]
10+
#[derive(Default)]
1011
pub enum RoutePreference {
1112
Low,
1213
Medium,
1314
High,
15+
#[default]
1416
Invalid,
1517
Other(u8),
1618
}
@@ -38,9 +40,3 @@ impl From<u8> for RoutePreference {
3840
}
3941
}
4042
}
41-
42-
impl Default for RoutePreference {
43-
fn default() -> Self {
44-
Self::Invalid
45-
}
46-
}

0 commit comments

Comments
 (0)