use alloc::rc::Rc;
use alloc::string::ToString;
use yew023::html::{ImplicitClone, IntoPropValue};
use yew023::virtual_dom::AttrValue;
use crate::Lang;
impl ImplicitClone for Lang {}
impl IntoPropValue<AttrValue> for Lang {
fn into_prop_value(self) -> AttrValue {
AttrValue::Rc(Rc::from(self.to_string()))
}
}
impl IntoPropValue<Option<AttrValue>> for Lang {
fn into_prop_value(self) -> Option<AttrValue> {
Some(self.into_prop_value())
}
}
#[cfg(test)]
mod tests {
use yew023::html::IntoPropValue;
use yew023::virtual_dom::AttrValue;
use crate::Lang;
#[test]
fn lang_attribute() {
let value: AttrValue = Lang::new("sv-SE").into_prop_value();
assert_eq!(&*value, "sv-SE");
let value: Option<AttrValue> = Lang::EN_US.into_prop_value();
assert_eq!(value.as_deref(), Some("en-US"));
}
}