Remove unused utils.

Co-authored-by: dasha_uwu <dasha@linuxping.win>
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk
2025-09-23 09:02:35 +00:00
parent 8f4cc87051
commit 86103183b3
5 changed files with 13 additions and 75 deletions

View File

@@ -1,7 +1,7 @@
mod expected;
mod tried;
use std::{cmp, convert::TryFrom};
use std::convert::TryFrom;
pub use checked_ops::checked_ops;
@@ -97,17 +97,11 @@ pub fn usize_from_u64_truncated(val: u64) -> usize { val as usize }
#[inline]
pub fn try_into<Dst: TryFrom<Src>, Src>(src: Src) -> Result<Dst> {
Dst::try_from(src).map_err(try_into_err::<Dst, Src>)
Dst::try_from(src).map_err(|_| {
err!(Arithmetic(
"failed to convert from {} to {}",
type_name::<Src>(),
type_name::<Dst>()
))
})
}
fn try_into_err<Dst: TryFrom<Src>, Src>(e: <Dst as TryFrom<Src>>::Error) -> Error {
drop(e);
err!(Arithmetic(
"failed to convert from {} to {}",
type_name::<Src>(),
type_name::<Dst>()
))
}
#[inline]
pub fn clamp<T: Ord>(val: T, min: T, max: T) -> T { cmp::min(cmp::max(val, min), max) }