use core::str::FromStr;
use super::Unit;
use crate::UnitParseError;
impl FromStr for Unit {
type Err = UnitParseError;
#[inline]
fn from_str(s: &str) -> Result<Self, Self::Err> {
Unit::parse_str(s, false, true)
}
}
impl From<Unit> for u128 {
#[inline]
fn from(unit: Unit) -> Self {
unit.as_bits_u128()
}
}
impl AsRef<str> for Unit {
#[inline]
fn as_ref(&self) -> &str {
self.as_str()
}
}