use typed_i18n::{BuilderFromRef, BuilderFromValue}; #[derive(PartialEq, Debug)] pub enum Output { Empty, Const(&'static str), Built(Vec>), } #[derive(PartialEq, Debug)] pub enum Element { Const(&'static str), String(String), T(T), } pub struct Tester(Vec>); impl typed_i18n::Builder for Tester { type Output = Output; fn empty() -> Self::Output { Output::Empty } fn const_str(i: &'static str) -> Self::Output { Output::Const(i) } fn new() -> Self { Tester(Vec::new()) } fn push_const_str(mut self, i: &'static str) -> Self { self.0.push(Element::Const(i)); self } fn push_str(mut self, i: &str) -> Self { self.0.push(Element::String(i.to_string())); self } fn finish(self) -> Self::Output { Output::Built(self.0) } } impl BuilderFromValue for Tester { fn push(mut self, i: T) -> Self { self.0.push(Element::T(i)); self } } impl BuilderFromRef for Tester { fn push(mut self, i: &str) -> Self { self.0.push(Element::T(i.to_string())); self } }