Skip to main content

NumberFormatter

Trait NumberFormatter 

Source
pub trait NumberFormatter: Sync {
    // Required methods
    fn format(
        &self,
        locale: &str,
        request: &NumberRequest<'_>,
        out: NumberOut<'_>,
    ) -> bool;
    fn plural(
        &self,
        locale: &str,
        request: &NumberRequest<'_>,
    ) -> Option<Category>;
}
Expand description

A number formatter for the intl option (Host::numbers; plans/03-runtime.md §2.7, §5.3): the final “value + resolved options → text” step and the plural category, where the numeric functions keep MF2’s semantics in Rust. mf2-host-web implements it with Intl.

Required Methods§

Source

fn format( &self, locale: &str, request: &NumberRequest<'_>, out: NumberOut<'_>, ) -> bool

Writes request formatted for locale — or, when request.neutral, in neutral symbols — as text or sub-parts, and returns true; false when it cannot (nothing written).

Source

fn plural(&self, locale: &str, request: &NumberRequest<'_>) -> Option<Category>

The plural category of request.value under its digit options and plural type (request.ordinal) for locale; None when it cannot.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§