pub enum FluentValue<'source> {
    String(Cow<'source, str>),
    Number(FluentNumber),
    Custom(Box<dyn FluentType + Send>),
    None,
    Error,
}
Expand description

The FluentValue enum represents values which can be formatted to a String.

Those values are either passed as arguments to FluentBundle::format_pattern or produced by functions, or generated in the process of pattern resolution.

Variants§

§

String(Cow<'source, str>)

§

Number(FluentNumber)

§

Custom(Box<dyn FluentType + Send>)

§

None

§

Error

Implementations§

§

impl<'source> FluentValue<'source>

pub fn try_number<S>(v: S) -> FluentValue<'source>
where S: ToString,

pub fn matches<R, M>( &self, other: &FluentValue<'_>, scope: &Scope<'_, '_, R, M> ) -> bool
where R: Borrow<FluentResource>, M: MemoizerKind,

pub fn write<W, R, M>( &self, w: &mut W, scope: &Scope<'_, '_, R, M> ) -> Result<(), Error>
where W: Write, R: Borrow<FluentResource>, M: MemoizerKind,

pub fn as_string<R, M>(&self, scope: &Scope<'_, '_, R, M>) -> Cow<'source, str>
where R: Borrow<FluentResource>, M: MemoizerKind,

Trait Implementations§

§

impl<'s> Clone for FluentValue<'s>

§

fn clone(&self) -> FluentValue<'s>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl<'source> Debug for FluentValue<'source>

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
§

impl<'source> From<&'source String> for FluentValue<'source>

§

fn from(s: &'source String) -> FluentValue<'source>

Converts to this type from the input type.
§

impl From<&f32> for FluentValue<'_>

§

fn from(n: &f32) -> FluentValue<'_>

Converts to this type from the input type.
§

impl From<&f64> for FluentValue<'_>

§

fn from(n: &f64) -> FluentValue<'_>

Converts to this type from the input type.
§

impl From<&i128> for FluentValue<'_>

§

fn from(n: &i128) -> FluentValue<'_>

Converts to this type from the input type.
§

impl From<&i16> for FluentValue<'_>

§

fn from(n: &i16) -> FluentValue<'_>

Converts to this type from the input type.
§

impl From<&i32> for FluentValue<'_>

§

fn from(n: &i32) -> FluentValue<'_>

Converts to this type from the input type.
§

impl From<&i64> for FluentValue<'_>

§

fn from(n: &i64) -> FluentValue<'_>

Converts to this type from the input type.
§

impl From<&i8> for FluentValue<'_>

§

fn from(n: &i8) -> FluentValue<'_>

Converts to this type from the input type.
§

impl From<&isize> for FluentValue<'_>

§

fn from(n: &isize) -> FluentValue<'_>

Converts to this type from the input type.
§

impl<'source> From<&'source str> for FluentValue<'source>

§

fn from(s: &'source str) -> FluentValue<'source>

Converts to this type from the input type.
§

impl From<&u128> for FluentValue<'_>

§

fn from(n: &u128) -> FluentValue<'_>

Converts to this type from the input type.
§

impl From<&u16> for FluentValue<'_>

§

fn from(n: &u16) -> FluentValue<'_>

Converts to this type from the input type.
§

impl From<&u32> for FluentValue<'_>

§

fn from(n: &u32) -> FluentValue<'_>

Converts to this type from the input type.
§

impl From<&u64> for FluentValue<'_>

§

fn from(n: &u64) -> FluentValue<'_>

Converts to this type from the input type.
§

impl From<&u8> for FluentValue<'_>

§

fn from(n: &u8) -> FluentValue<'_>

Converts to this type from the input type.
§

impl From<&usize> for FluentValue<'_>

§

fn from(n: &usize) -> FluentValue<'_>

Converts to this type from the input type.
§

impl<'source> From<Cow<'source, str>> for FluentValue<'source>

§

fn from(s: Cow<'source, str>) -> FluentValue<'source>

Converts to this type from the input type.
§

impl<'l> From<FluentNumber> for FluentValue<'l>

§

fn from(input: FluentNumber) -> FluentValue<'l>

Converts to this type from the input type.
§

impl<'source> From<String> for FluentValue<'source>

§

fn from(s: String) -> FluentValue<'source>

Converts to this type from the input type.
§

impl From<f32> for FluentValue<'_>

§

fn from(n: f32) -> FluentValue<'_>

Converts to this type from the input type.
§

impl From<f64> for FluentValue<'_>

§

fn from(n: f64) -> FluentValue<'_>

Converts to this type from the input type.
§

impl From<i128> for FluentValue<'_>

§

fn from(n: i128) -> FluentValue<'_>

Converts to this type from the input type.
§

impl From<i16> for FluentValue<'_>

§

fn from(n: i16) -> FluentValue<'_>

Converts to this type from the input type.
§

impl From<i32> for FluentValue<'_>

§

fn from(n: i32) -> FluentValue<'_>

Converts to this type from the input type.
§

impl From<i64> for FluentValue<'_>

§

fn from(n: i64) -> FluentValue<'_>

Converts to this type from the input type.
§

impl From<i8> for FluentValue<'_>

§

fn from(n: i8) -> FluentValue<'_>

Converts to this type from the input type.
§

impl From<isize> for FluentValue<'_>

§

fn from(n: isize) -> FluentValue<'_>

Converts to this type from the input type.
§

impl From<u128> for FluentValue<'_>

§

fn from(n: u128) -> FluentValue<'_>

Converts to this type from the input type.
§

impl From<u16> for FluentValue<'_>

§

fn from(n: u16) -> FluentValue<'_>

Converts to this type from the input type.
§

impl From<u32> for FluentValue<'_>

§

fn from(n: u32) -> FluentValue<'_>

Converts to this type from the input type.
§

impl From<u64> for FluentValue<'_>

§

fn from(n: u64) -> FluentValue<'_>

Converts to this type from the input type.
§

impl From<u8> for FluentValue<'_>

§

fn from(n: u8) -> FluentValue<'_>

Converts to this type from the input type.
§

impl From<usize> for FluentValue<'_>

§

fn from(n: usize) -> FluentValue<'_>

Converts to this type from the input type.
§

impl<'s> PartialEq for FluentValue<'s>

§

fn eq(&self, other: &FluentValue<'s>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

Auto Trait Implementations§

§

impl<'source> !RefUnwindSafe for FluentValue<'source>

§

impl<'source> Send for FluentValue<'source>

§

impl<'source> !Sync for FluentValue<'source>

§

impl<'source> Unpin for FluentValue<'source>

§

impl<'source> !UnwindSafe for FluentValue<'source>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> AnyEq for T
where T: Any + PartialEq,

§

fn equals(&self, other: &(dyn Any + 'static)) -> bool

§

fn as_any(&self) -> &(dyn Any + 'static)

source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more