oxedyne/fe2o3/fe2o3_core/src/id.rs
712 bytes, 1 run
created by r1870400018:80, which is this file's identity for as long as the history lasts, whatever it is later renamed to
download · who wrote it · its history
| 1 | use crate::prelude::*; |
| 2 | |
| 3 | |
| 4 | pub trait ParseId<const L: usize> { |
| 5 | fn parse_id(s: &str) -> Outcome<Self> where Self: Sized; |
| 6 | } |
| 7 | |
| 8 | impl ParseId<1> for u8 { |
| 9 | fn parse_id(s: &str) -> Outcome<Self> { |
| 10 | Ok(res!(u8::from_str(s))) |
| 11 | } |
| 12 | } |
| 13 | impl ParseId<2> for u16 { |
| 14 | fn parse_id(s: &str) -> Outcome<Self> { |
| 15 | Ok(res!(u16::from_str(s))) |
| 16 | } |
| 17 | } |
| 18 | impl ParseId<4> for u32 { |
| 19 | fn parse_id(s: &str) -> Outcome<Self> { |
| 20 | Ok(res!(u32::from_str(s))) |
| 21 | } |
| 22 | } |
| 23 | impl ParseId<8> for u64 { |
| 24 | fn parse_id(s: &str) -> Outcome<Self> { |
| 25 | Ok(res!(u64::from_str(s))) |
| 26 | } |
| 27 | } |
| 28 | impl ParseId<16> for u128 { |
| 29 | fn parse_id(s: &str) -> Outcome<Self> { |
| 30 | Ok(res!(u128::from_str(s))) |
| 31 | } |
| 32 | } |
| 33 |