#![allow(clippy::used_underscore_binding, clippy::all, warnings, missing_docs)]
#[ allow( unused_imports ) ]
use super::*;
#[ allow( unused_imports ) ]
use test_tools::a_id;
#[ derive( Debug, PartialEq, the_module::Former ) ]
pub struct StructWithCustomSetters {
ordinary: String,
#[ scalar( setter = false ) ]
magic: String,
}
impl<Definition> StructWithCustomSettersFormer<Definition>
where
Definition: former::FormerDefinition<Storage = StructWithCustomSettersFormerStorage>,
{
fn ordinary_exclamaited<IntoString>(mut self, val: IntoString) -> Self
where
IntoString: Into<String>,
{
debug_assert!(self.storage.ordinary.is_none());
self.storage.ordinary = Some(format!("{}!", val.into()));
self
}
fn magic<IntoString>(mut self, val: IntoString) -> Self
where
IntoString: Into<String>,
{
debug_assert!(self.storage.magic.is_none());
self.storage.magic = Some(format!("Some magic : < {} >", val.into()));
self
}
}
#[ test ]
fn basic() {
let got = StructWithCustomSetters::former().ordinary("val1").magic("val2").form();
let exp = StructWithCustomSetters {
ordinary: "val1".to_string(),
magic: "Some magic : < val2 >".to_string(),
};
a_id!(got, exp);
let got = StructWithCustomSetters::former().ordinary_exclamaited("val1").form();
let exp = StructWithCustomSetters {
ordinary: "val1!".to_string(),
magic: String::new(),
};
a_id!(got, exp);
}