pub struct LiteralValue {
pub value: ValueKind,
pub lemma_type: Arc<LemmaType>,
}Expand description
Literal value with type. The single value type in semantics.
Fields§
§value: ValueKind§lemma_type: Arc<LemmaType>Implementations§
Source§impl LiteralValue
impl LiteralValue
pub fn text(s: String) -> Self
pub fn text_with_type(s: String, lemma_type: Arc<LemmaType>) -> Self
pub fn number(n: Ratio<i128>) -> Self
pub fn number_from_decimal(decimal: Decimal) -> Self
pub fn number_with_type(n: Ratio<i128>, lemma_type: Arc<LemmaType>) -> Self
pub fn number_with_type_from_decimal( decimal: Decimal, lemma_type: Arc<LemmaType>, ) -> Self
Sourcepub fn quantity_with_type(
n: Ratio<i128>,
unit: String,
lemma_type: Arc<LemmaType>,
) -> Self
pub fn quantity_with_type( n: Ratio<i128>, unit: String, lemma_type: Arc<LemmaType>, ) -> Self
Build a Quantity literal carrying a single user-typed unit name.
The signature is [(unit_name, 1)]; the normalize pass expands compound names
against unit_index so all stored signatures end up in canonical (base-unit) form.
Sourcepub fn quantity_with_signature(
n: Ratio<i128>,
signature: Vec<(String, i32)>,
lemma_type: Arc<LemmaType>,
) -> Self
pub fn quantity_with_signature( n: Ratio<i128>, signature: Vec<(String, i32)>, lemma_type: Arc<LemmaType>, ) -> Self
Build a Quantity literal with an explicit signature (already in canonical form). Used by arithmetic when combining operand signatures yields a multi-term result.
Sourcepub fn number_interpreted_as_quantity(
value: Ratio<i128>,
unit_name: String,
) -> Self
pub fn number_interpreted_as_quantity( value: Ratio<i128>, unit_name: String, ) -> Self
Number interpreted as a quantity value in the given unit (e.g. “3 as usd” where 3 is a number). Creates an anonymous one-unit quantity type so computation does not depend on parsing types.
pub fn from_bool(b: bool) -> Self
pub fn from_datetime(dt: &DateTimeValue) -> Self
Sourcepub fn magnitude_default_for_decimal_prompt(&self) -> Option<String>
pub fn magnitude_default_for_decimal_prompt(&self) -> Option<String>
Magnitude string for decimal input prompts (number, single-unit quantity, ratio with percent/permille scaling).
pub fn date(dt: SemanticDateTime) -> Self
pub fn date_with_type(dt: SemanticDateTime, lemma_type: Arc<LemmaType>) -> Self
pub fn time(t: SemanticTime) -> Self
pub fn time_with_type(t: SemanticTime, lemma_type: Arc<LemmaType>) -> Self
pub fn calendar( value: Ratio<i128>, unit: SemanticCalendarUnit, lemma_type: Arc<LemmaType>, ) -> Self
pub fn calendar_from_decimal( value: Decimal, unit: SemanticCalendarUnit, lemma_type: Arc<LemmaType>, ) -> Self
pub fn calendar_with_type( value: Ratio<i128>, unit: SemanticCalendarUnit, lemma_type: Arc<LemmaType>, ) -> Self
Sourcepub fn duration_canonical_seconds(&self) -> Ratio<i128>
pub fn duration_canonical_seconds(&self) -> Ratio<i128>
Derive seconds from a duration quantity’s canonical magnitude.
Sourcepub fn calendar_canonical_months(&self) -> Ratio<i128>
pub fn calendar_canonical_months(&self) -> Ratio<i128>
Derive months from a calendar quantity’s canonical magnitude.
pub fn ratio(r: Ratio<i128>, unit: Option<String>) -> Self
pub fn ratio_from_decimal(r: Decimal, unit: Option<String>) -> Self
pub fn ratio_with_type( r: Ratio<i128>, unit: Option<String>, lemma_type: Arc<LemmaType>, ) -> Self
pub fn range(left: LiteralValue, right: LiteralValue) -> 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
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
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>,
Source§impl Display for LiteralValue
impl Display for LiteralValue
impl Eq for LiteralValue
Source§impl Hash for LiteralValue
impl Hash for LiteralValue
Source§impl PartialEq for LiteralValue
impl PartialEq for LiteralValue
Source§fn eq(&self, other: &LiteralValue) -> bool
fn eq(&self, other: &LiteralValue) -> bool
self and other values to be equal, and is used by ==.Source§impl Serialize for LiteralValue
impl Serialize 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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
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>
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>
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