Skip to content

Commit fd280d5

Browse files
committed
Make can::Id usable as key in BTreeMap and HashMap by implementing Ord and Hash
1 parent aa74081 commit fd280d5

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/can/id.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! CAN Identifiers.
22
33
/// Standard 11-bit CAN Identifier (`0..=0x7FF`).
4-
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
4+
#[derive(Debug, Copy, Clone, Eq, PartialEq, PartialOrd, Ord, Hash)]
55
pub struct StandardId(u16);
66

77
impl StandardId {
@@ -40,7 +40,7 @@ impl StandardId {
4040
}
4141

4242
/// Extended 29-bit CAN Identifier (`0..=1FFF_FFFF`).
43-
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
43+
#[derive(Debug, Copy, Clone, Eq, PartialEq, PartialOrd, Ord, Hash)]
4444
pub struct ExtendedId(u32);
4545

4646
impl ExtendedId {
@@ -85,7 +85,7 @@ impl ExtendedId {
8585
}
8686

8787
/// A CAN Identifier (standard or extended).
88-
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
88+
#[derive(Debug, Copy, Clone, Eq, PartialEq, PartialOrd, Ord, Hash)]
8989
pub enum Id {
9090
/// Standard 11-bit Identifier (`0..=0x7FF`).
9191
Standard(StandardId),

0 commit comments

Comments
 (0)