Add impl From<i16> for angle and length

This commit is contained in:
Dietrich 2022-12-07 13:51:08 +01:00
parent e0926a00f7
commit 009f896e08
2 changed files with 14 additions and 0 deletions

View File

@ -23,6 +23,14 @@ pub struct Angle<T: Default> {
value: AngleUnit<T>, value: AngleUnit<T>,
} }
impl<T: From<i16> + Default> From<i16> for Angle<T> {
fn from(i: i16) -> Self {
Self {
value: AngleUnit::Degrees(T::from(i)),
}
}
}
impl<T: Default + Clone + Rem<T, Output = T>> Rem<T> for Angle<T> { impl<T: Default + Clone + Rem<T, Output = T>> Rem<T> for Angle<T> {
type Output = Self; type Output = Self;

View File

@ -4,3 +4,9 @@ use super::Precision;
#[derive(Inspectable, Default, Copy, Clone, Debug)] #[derive(Inspectable, Default, Copy, Clone, Debug)]
pub struct Length(pub Precision); pub struct Length(pub Precision);
impl From<i16> for Length {
fn from(i: i16) -> Self {
Self(Precision::from(i))
}
}