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 }
}
impl ToF32 for f64 {
#[allow(clippy::cast_possible_truncation)]
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 }
}
impl ToI32 for f64 {
#[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 }
}
impl ToU32 for u64 {
#[allow(clippy::cast_possible_truncation)]
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 }
}
pub trait ToU8 {
fn to_u8(self) -> u8;
}
impl ToU8 for f32 {
#[allow(clippy::cast_possible_truncation, clippy::cast_sign_loss)]
fn to_u8(self) -> u8 { self as u8 }
}
impl ToU8 for u32 {
#[allow(clippy::cast_possible_truncation)]
fn to_u8(self) -> u8 { self as u8 }
}
impl ToU8 for usize {
#[allow(clippy::cast_possible_truncation)]
fn to_u8(self) -> u8 { self as u8 }
}
pub trait ToU16 {
fn to_u16(self) -> u16;
}
impl ToU16 for usize {
#[allow(clippy::cast_possible_truncation)]
fn to_u16(self) -> u16 { self as u16 }
}
impl ToU16 for u32 {
#[allow(clippy::cast_possible_truncation)]
fn to_u16(self) -> u16 { self as u16 }
}
impl ToU16 for f32 {
#[allow(clippy::cast_possible_truncation, clippy::cast_sign_loss)]
fn to_u16(self) -> u16 { self as u16 }
}
pub trait ToF64 {
fn to_f64(self) -> f64;
}
impl ToF64 for usize {
#[allow(clippy::cast_precision_loss)]
fn to_f64(self) -> f64 { self as f64 }
}
impl ToF64 for u32 {
fn to_f64(self) -> f64 { f64::from(self) }
}
impl ToF64 for i32 {
fn to_f64(self) -> f64 { f64::from(self) }
}
impl ToF64 for f32 {
fn to_f64(self) -> f64 { f64::from(self) }
}