pub struct Units(/* private fields */);
Implementations§
Source§impl Units
impl Units
Sourcepub fn get_unit_type(&self) -> UnitType
pub fn get_unit_type(&self) -> UnitType
Sourcepub fn get_unit_value(&self) -> f32
pub fn get_unit_value(&self) -> f32
Sourcepub fn from_pixels(px: i32) -> Units
pub fn from_pixels(px: i32) -> Units
Sourcepub fn from_string(str: &str) -> Option<Units>
pub fn from_string(str: &str) -> Option<Units>
Parses a value and updates units
with it
A Units
expressed in string should match:
units: wsp* unit-value wsp* unit-name? wsp*
unit-value: number
unit-name: 'px' | 'pt' | 'mm' | 'em' | 'cm'
number: digit+
| digit* sep digit+
sep: '.' | ','
digit: '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9'
wsp: (#0x20 | #0x9 | #0xA | #0xB | #0xC | #0xD)+
For instance, these are valid strings:
10 px
5.1 em
24 pt
12.6 mm
.3 cm
While these are not:
42 cats
omg!1!ponies
If no unit is specified, pixels are assumed.
§units
a Units
§str
the string to convert
§Returns
true
if the string was successfully parsed,
and false
otherwise
Trait Implementations§
Source§impl Ord for Units
impl Ord for Units
Source§impl PartialOrd for Units
impl PartialOrd for Units
Source§impl StaticType for Units
impl StaticType for Units
Source§fn static_type() -> Type
fn static_type() -> Type
Returns the type identifier of
Self
.impl Eq for Units
impl StructuralPartialEq for Units
Auto Trait Implementations§
impl Freeze for Units
impl RefUnwindSafe for Units
impl !Send for Units
impl !Sync for Units
impl Unpin for Units
impl UnwindSafe for Units
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more