pub trait ToF32 {
fn to_f32(self) -> f32;
}
impl ToF32 for i32 {
#[allow(clippy::cast_precision_loss)]
fn to_f32(self) -> f32 { self as f32 }
}
impl ToF32 for u32 {
#[allow(clippy::cast_precision_loss)]
fn to_f32(self) -> f32 { self as f32 }
}
impl ToF32 for usize {
#[allow(clippy::cast_precision_loss)]
fn to_f32(self) -> f32 { self as f32 }
}
pub trait ToI32 {
fn to_i32(self) -> i32;
}
impl ToI32 for usize {
#[allow(clippy::cast_possible_truncation, clippy::cast_possible_wrap)]
fn to_i32(self) -> i32 { self as i32 }
}
impl ToI32 for u32 {
#[allow(clippy::cast_possible_wrap)]
fn to_i32(self) -> i32 { self as i32 }
}
impl ToI32 for f32 {
#[allow(clippy::cast_possible_truncation)]
fn to_i32(self) -> i32 { self as i32 }
}
pub trait ToU32 {
fn to_u32(self) -> u32;
}
impl ToU32 for usize {
#[allow(clippy::cast_possible_truncation)]
fn to_u32(self) -> u32 { self as u32 }
}
impl ToU32 for f32 {
#[allow(clippy::cast_possible_truncation, clippy::cast_sign_loss)]
fn to_u32(self) -> u32 { self as u32 }
}
impl ToU32 for f64 {
#[allow(clippy::cast_possible_truncation, clippy::cast_sign_loss)]
fn to_u32(self) -> u32 { self as u32 }
}
pub trait ToUsize {
fn to_usize(self) -> usize;
}
impl ToUsize for u32 {
fn to_usize(self) -> usize { self as usize }
}
impl ToUsize for f32 {
#[allow(clippy::cast_possible_truncation, clippy::cast_sign_loss)]
fn to_usize(self) -> usize { self as usize }
}