1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
use core::fmt;
pub use core::convert::From;
#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct DeviceID {
pub(crate) inner: usize,
}
impl DeviceID {
pub(crate) fn new(inner: usize) -> DeviceID {
DeviceID { inner }
}
}
impl From<DeviceID> for usize {
fn from(did: DeviceID) -> usize { did.inner }
}
impl fmt::Debug for DeviceID {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_fmt(format_args!("DeviceID<{:x}>", self.inner))
}
}
impl fmt::Display for DeviceID {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_fmt(format_args!("DeviceID<{:x}>", self.inner))
}
}