1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
pub(crate) trait IntoUsize { fn into_usize(self) -> usize; } impl IntoUsize for u32 { fn into_usize(self) -> usize { self.try_into().unwrap() } } #[cfg(test)] mod tests { use super::*; #[test] fn into_usize() { u32::MAX.into_usize(); } }