pub struct LocaleFallbackSolver<R: for<'a> PolyL10nRulebook<'a> = ARulebook> {
pub rulebook: R,
}Expand description
Entry point of poly_l10n.
A solver requires a Rulebook or ARulebook to process and solve locales. The latter is
used by Self::default.
§Examples
let solver = poly_l10n::LocaleFallbackSolver::<poly_l10n::ARulebook>::default();
assert_eq!(solver.solve_locale(poly_l10n::langid!("arb")), poly_l10n::langid!["arb", "ar-AE", "ara-AE", "arb-AE", "ar", "ara"]);Fields§
§rulebook: RImplementations§
Source§impl<R: for<'a> PolyL10nRulebook<'a>> LocaleFallbackSolver<R>
impl<R: for<'a> PolyL10nRulebook<'a>> LocaleFallbackSolver<R>
Sourcepub fn solve_locale<L: AsRef<LanguageIdentifier>>(
&self,
locale: L,
) -> Vec<LanguageIdentifier>
pub fn solve_locale<L: AsRef<LanguageIdentifier>>( &self, locale: L, ) -> Vec<LanguageIdentifier>
Find alternative fallbacks for the given locale as specified by the rulebook. This
operation is recursive and expensive.
let solver = poly_l10n::LocaleFallbackSolver::<poly_l10n::Rulebook>::default();
assert_eq!(solver.solve_locale(poly_l10n::langid!("arb")), poly_l10n::langid!["arb", "ar-AE", "ara-AE", "arb-AE", "ar", "ara"]);Trait Implementations§
Source§impl<R: Clone + for<'a> PolyL10nRulebook<'a>> Clone for LocaleFallbackSolver<R>
impl<R: Clone + for<'a> PolyL10nRulebook<'a>> Clone for LocaleFallbackSolver<R>
Source§fn clone(&self) -> LocaleFallbackSolver<R>
fn clone(&self) -> LocaleFallbackSolver<R>
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<R: Debug + for<'a> PolyL10nRulebook<'a>> Debug for LocaleFallbackSolver<R>
impl<R: Debug + for<'a> PolyL10nRulebook<'a>> Debug for LocaleFallbackSolver<R>
Source§impl<R: Default + for<'a> PolyL10nRulebook<'a>> Default for LocaleFallbackSolver<R>
impl<R: Default + for<'a> PolyL10nRulebook<'a>> Default for LocaleFallbackSolver<R>
Source§fn default() -> LocaleFallbackSolver<R>
fn default() -> LocaleFallbackSolver<R>
Returns the “default value” for a type. Read more
impl<R: Copy + for<'a> PolyL10nRulebook<'a>> Copy for LocaleFallbackSolver<R>
Auto Trait Implementations§
impl<R> Freeze for LocaleFallbackSolver<R>where
R: Freeze,
impl<R> RefUnwindSafe for LocaleFallbackSolver<R>where
R: RefUnwindSafe,
impl<R> Send for LocaleFallbackSolver<R>where
R: Send,
impl<R> Sync for LocaleFallbackSolver<R>where
R: Sync,
impl<R> Unpin for LocaleFallbackSolver<R>where
R: Unpin,
impl<R> UnwindSafe for LocaleFallbackSolver<R>where
R: UnwindSafe,
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<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 more