[−][src]Struct raystack::Number
A Haystack Number, encapsulating a scalar value and an optional unit value. The unit is represented as a string.
Methods
impl Number
[src]
pub fn new(value: f64, unit: Option<String>) -> Self
[src]
Create a new Number
. If present, the unit should
be a valid unit string from Project Haystack's
unit database.
pub fn value(&self) -> f64
[src]
Return the numeric component of this Number
.
pub fn unit(&self) -> Option<&str>
[src]
Return the unit component of this Number
, if present.
pub fn from_encoded_json_string(
json_string: &str
) -> Result<Self, ParseNumberError>
[src]
json_string: &str
) -> Result<Self, ParseNumberError>
Parse a Number
from a number encoded in a JSON string.
Example
use raystack::Number; let n = Number::new(1.0, Some("pH".to_owned())); assert_eq!(Number::from_encoded_json_string("n:1.0 pH").unwrap(), n);
Trait Implementations
Auto Trait Implementations
impl Unpin for Number
impl Sync for Number
impl Send for Number
impl UnwindSafe for Number
impl RefUnwindSafe for Number
Blanket Implementations
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,
fn vzip(self) -> V
impl<T> Erased for T
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
U: TryFrom<T>,