diff options
author | jelemux <jeremias.weber@protonmail.com> | 2021-02-11 12:07:22 +0100 |
---|---|---|
committer | jelemux <jeremias.weber@protonmail.com> | 2021-02-11 12:07:22 +0100 |
commit | 0660151a8b641fa0a23dde2598132029970f7ae4 (patch) | |
tree | 0bdeb1108419add4570f278795f0bfd0f5366856 /src/viewmodel/vcard.rs | |
parent | 036a567bae8346eb38f9237f59645dbcc4f1cd8c (diff) | |
download | wasm-card-0660151a8b641fa0a23dde2598132029970f7ae4.tar.gz wasm-card-0660151a8b641fa0a23dde2598132029970f7ae4.tar.bz2 |
refactoring - reduced code size by about a third
Diffstat (limited to 'src/viewmodel/vcard.rs')
-rw-r--r-- | src/viewmodel/vcard.rs | 40 |
1 files changed, 0 insertions, 40 deletions
diff --git a/src/viewmodel/vcard.rs b/src/viewmodel/vcard.rs deleted file mode 100644 index 18ce43a..0000000 --- a/src/viewmodel/vcard.rs +++ /dev/null @@ -1,40 +0,0 @@ -use crate::viewmodel::address::Address; -use crate::viewmodel::dates::Dates; -use crate::viewmodel::name::Name; -use crate::viewmodel::organizational::Organizational; -use crate::viewmodel::telephone::Telephone; - -/// Type that represents the data structure of a vcard. -#[derive(Clone, Debug)] -pub struct VCardData { - pub names: Vec<Name>, - pub addresses: Vec<Address>, - pub telephones: Vec<Telephone>, - pub datess: Vec<Dates>, - pub organizationals: Vec<Organizational>, -} - -macro_rules! make_vec_adder_fn { - ( 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(), - datess: Vec::new(), - organizationals: Vec::new(), - } - } - make_vec_adder_fn!( fn add_name names => name: Name ); - make_vec_adder_fn!( fn add_address addresses => address: Address ); - make_vec_adder_fn!( fn add_telephone telephones => telephone: Telephone ); - make_vec_adder_fn!( fn add_dates datess => dates: Dates ); - make_vec_adder_fn!( fn add_organizational organizationals => organizational: Organizational ); -} |