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.
Object Safety§
This trait is not object safe.