pub enum Datum {
Binary(bool),
Continuous(f64),
Categorical(Category),
Count(u32),
Missing,
}Expand description
Represents the types of data lace can work with
Variants§
Implementations§
Source§impl Datum
impl Datum
Sourcepub fn to_f64_opt(&self) -> Option<f64>
pub fn to_f64_opt(&self) -> Option<f64>
Unwraps the datum as an f64 if possible. The conversion will coerce
from other types if possible.
§Example
assert_eq!(Datum::Continuous(1.2).to_f64_opt(), Some(1.2));
assert_eq!(Datum::Categorical(true.into()).to_f64_opt(), Some(1.0));
assert_eq!(Datum::Categorical(8_u8.into()).to_f64_opt(), Some(8.0));
assert_eq!(Datum::Categorical("cat".into()).to_f64_opt(), None);
assert_eq!(Datum::Missing.to_f64_opt(), None);Sourcepub fn to_u8_opt(&self) -> Option<u8>
pub fn to_u8_opt(&self) -> Option<u8>
Unwraps the datum as an u8 if possible. The conversion will coerce
from other types if possible.
§Example
assert_eq!(Datum::Continuous(1.2).to_u8_opt(), None);
assert_eq!(Datum::Categorical(8_u8.into()).to_u8_opt(), Some(8));
assert_eq!(Datum::Categorical(true.into()).to_u8_opt(), Some(1));
assert_eq!(Datum::Categorical("cat".into()).to_u8_opt(), None);
assert_eq!(Datum::Missing.to_u8_opt(), None);Sourcepub fn is_continuous(&self) -> bool
pub fn is_continuous(&self) -> bool
Returns true if the Datum is continuous
Sourcepub fn is_categorical(&self) -> bool
pub fn is_categorical(&self) -> bool
Returns true if the Datum is categorical
Sourcepub fn is_missing(&self) -> bool
pub fn is_missing(&self) -> bool
Returns true if the Datum is missing
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Datum
impl<'de> Deserialize<'de> for Datum
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialOrd for Datum
impl PartialOrd for Datum
Auto Trait Implementations§
impl Freeze for Datum
impl RefUnwindSafe for Datum
impl Send for Datum
impl Sync for Datum
impl Unpin for Datum
impl UnwindSafe for Datum
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more