es_fluent/traits/
fluent_display.rs1use std::fmt;
2
3pub trait FluentDisplay {
9 fn fluent_fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result;
11}
12
13pub trait ToFluentString {
15 fn to_fluent_string(&self) -> String;
17}
18
19impl<T: FluentDisplay + ?Sized> ToFluentString for T {
20 fn to_fluent_string(&self) -> String {
21 struct FluentDisplayWrapper<'a, T: ?Sized> {
22 inner: &'a T,
23 }
24
25 impl<'a, T: FluentDisplay + ?Sized> fmt::Display for FluentDisplayWrapper<'a, T> {
26 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
27 self.inner.fluent_fmt(f)
28 }
29 }
30
31 FluentDisplayWrapper { inner: self }.to_string()
32 }
33}