http_path_params/id.rs
1use core::{num::ParseIntError, str::FromStr};
2
3//
4#[derive(Debug, Copy, Clone, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
5pub struct Id(pub usize);
6
7impl core::fmt::Display for Id {
8 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
9 write!(f, "{}", self.0)
10 }
11}
12
13impl FromStr for Id {
14 type Err = ParseIntError;
15
16 fn from_str(s: &str) -> Result<Self, Self::Err> {
17 Ok(Self(s.parse::<usize>()?))
18 }
19}