FluentType in rustc_error_messages - Rust
Description: Custom types can implement the `FluentType` trait in order to generate a string value for use in the message generation process.

Skip to main content

## FluentType

# Trait FluentType

Source

    pub trait FluentType:
        Debug
        + AnyEq
        + 'static {
        // Required methods
        fn duplicate(&self) -> Box<dyn FluentType + Send>;
        fn as_string(&self, intls: &IntlLangMemoizer) -> Cow<'static, str>;
        fn as_string_threadsafe(
            &self,
            intls: &IntlLangMemoizer,
        ) -> Cow<'static, str>;
    }

Expand description

Custom types can implement the `FluentType` trait in order to generate a string value for use in the message generation process.

## Required Methods§

Source

#### fn duplicate(&self) -> Box<dyn FluentType + Send>

Create a clone of the underlying type.

Source

#### fn as_string(&self, intls: &IntlLangMemoizer) -> Cow<'static, str>

Convert the custom type into a string value, for instance a custom `DateTime` type could return “Oct. 27, 2022”.

Source

#### fn as_string_threadsafe(&self, intls: &IntlLangMemoizer) -> Cow<'static, str>

Convert the custom type into a string value, for instance a custom `DateTime` type could return “Oct. 27, 2022”. This operation is provided the threadsafe `IntlLangMemoizer`.

## Trait Implementations§

Source§

### impl PartialEq for dyn FluentType + Send

Source§

#### fn eq(&self, other: &(dyn FluentType + Send + 'static)) -> bool

Tests for `self` and `other` values to be equal, and is used by `==`.
1.0.0 · Source§

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

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

## Implementors§