pub struct LiteralValue {
pub value: ValueKind,
pub lemma_type: LemmaType,
}Expand description
Literal value with type. The single value type in semantics.
Fields§
§value: ValueKind§lemma_type: LemmaTypeImplementations§
Source§impl LiteralValue
impl LiteralValue
pub fn text(s: String) -> Self
pub fn text_with_type(s: String, lemma_type: LemmaType) -> Self
pub fn number(n: Decimal) -> Self
pub fn number_with_type(n: Decimal, lemma_type: LemmaType) -> Self
pub fn scale_with_type(n: Decimal, unit: String, lemma_type: LemmaType) -> Self
Sourcepub fn number_interpreted_as_scale(value: Decimal, unit_name: String) -> Self
pub fn number_interpreted_as_scale(value: Decimal, unit_name: String) -> Self
Number interpreted as a scale value in the given unit (e.g. “3 in usd” where 3 is a number). Creates an anonymous one-unit scale type so computation does not depend on parsing types.
pub fn from_bool(b: bool) -> Self
pub fn date(dt: SemanticDateTime) -> Self
pub fn date_with_type(dt: SemanticDateTime, lemma_type: LemmaType) -> Self
pub fn time(t: SemanticTime) -> Self
pub fn time_with_type(t: SemanticTime, lemma_type: LemmaType) -> Self
pub fn duration(value: Decimal, unit: SemanticDurationUnit) -> Self
pub fn duration_with_type( value: Decimal, unit: SemanticDurationUnit, lemma_type: LemmaType, ) -> Self
pub fn ratio(r: Decimal, unit: Option<String>) -> Self
pub fn ratio_with_type( r: Decimal, unit: Option<String>, lemma_type: LemmaType, ) -> Self
Sourcepub fn display_value(&self) -> String
pub fn display_value(&self) -> String
Get a display string for this value (for UI/output)
Trait Implementations§
Source§impl Clone for LiteralValue
impl Clone for LiteralValue
Source§fn clone(&self) -> LiteralValue
fn clone(&self) -> LiteralValue
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for LiteralValue
impl Debug for LiteralValue
Source§impl<'de> Deserialize<'de> for LiteralValue
impl<'de> Deserialize<'de> for LiteralValue
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 Display for LiteralValue
impl Display for LiteralValue
Source§impl Hash for LiteralValue
impl Hash for LiteralValue
Source§impl PartialEq for LiteralValue
impl PartialEq for LiteralValue
Source§impl Serialize for LiteralValue
impl Serialize for LiteralValue
impl Eq for LiteralValue
impl StructuralPartialEq for LiteralValue
Auto Trait Implementations§
impl Freeze for LiteralValue
impl RefUnwindSafe for LiteralValue
impl Send for LiteralValue
impl Sync for LiteralValue
impl Unpin for LiteralValue
impl UnsafeUnpin for LiteralValue
impl UnwindSafe for LiteralValue
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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 moreSource§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.