#![allow(missing_docs)]
#[cfg(any(not(feature = "derive_former"), not(feature = "enabled")))]
fn main() {}
#[cfg(all(feature = "derive_former", feature = "enabled"))]
fn main() {
#[ cfg( feature = "enabled" ) ]
use former::Former;
#[ derive( Debug, Former ) ]
pub struct StructWithCustomSetters {
word: String,
}
impl StructWithCustomSettersFormer {
pub fn word_exclaimed(mut self, value: impl Into<String>) -> Self {
debug_assert!(self.storage.word.is_none());
self.storage.word = Some(format!("{}!", value.into()));
self
}
}
let example = StructWithCustomSetters::former().word("Hello").form();
assert_eq!(example.word, "Hello".to_string());
let example = StructWithCustomSetters::former().word_exclaimed("Hello").form();
assert_eq!(example.word, "Hello!".to_string());
}