pub trait Unit: Sized {
    type U;
    type T: Prefix;
    // Required methods
    fn value(&self) -> Self::U;
    fn prefix(&self) -> Self::T;
    fn suffixes() -> &'static [&'static str];
    fn convert(&self, prefix: Self::T) -> Result<Self, String>
       where Self: Sized;
    fn convert_lossy(&self, prefix: Self::T) -> Self
       where Self: Sized;
}Expand description
A unit containing a value (ex: an integer), a prefix (ex: an enum), and allowed constant suffix strings.
Required Associated Types§
Required Methods§
fn suffixes() -> &'static [&'static str]
Sourcefn convert(&self, prefix: Self::T) -> Result<Self, String>where
    Self: Sized,
 
fn convert(&self, prefix: Self::T) -> Result<Self, String>where
    Self: Sized,
Convert value to a different prefix, but return an error if the conversion cannot be done without possibly losing precision.
Sourcefn convert_lossy(&self, prefix: Self::T) -> Selfwhere
    Self: Sized,
 
fn convert_lossy(&self, prefix: Self::T) -> Selfwhere
    Self: Sized,
Convert value to a different prefix, even if it loses precision.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.