From 51bf8e89ce07864b70d7138bbc3958faf499cc67 Mon Sep 17 00:00:00 2001 From: jelemux Date: Wed, 3 Feb 2021 07:08:49 +0100 Subject: now it compiles --- src/viewmodel/vcard.rs | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/viewmodel/vcard.rs (limited to 'src/viewmodel/vcard.rs') diff --git a/src/viewmodel/vcard.rs b/src/viewmodel/vcard.rs new file mode 100644 index 0000000..2d415b7 --- /dev/null +++ b/src/viewmodel/vcard.rs @@ -0,0 +1,32 @@ +use yewtil::ptr::Irc; +use crate::viewmodel::telephone::Telephone; +use crate::viewmodel::address::Address; +use crate::viewmodel::name::Name; + +#[derive(Clone, Debug)] +pub struct VCardData { + pub names: Vec>, + pub addresses: Vec>, + pub telephones: Vec>, +} + +macro_rules! make_vec_adder_fn { + ( $fnname:ident $property:ident $($arg_name:ident : $arg_type:ty),* ) => { + pub fn $fnname(&mut self, $( $arg_name : $arg_type ),*) { + $(self.$property.push($arg_name);)* + } + }; +} + +impl VCardData { + pub fn new() -> Self { + Self { + names: Vec::new(), + addresses: Vec::new(), + telephones: Vec::new(), + } + } + make_vec_adder_fn!( add_name names name: Irc ); + make_vec_adder_fn!( add_address addresses address: Irc
); + make_vec_adder_fn!( add_telephone telephones telephone: Irc ); +} \ No newline at end of file -- cgit v1.2.3