fhir_rs/datatype/
macros.rs1
2#[macro_export]
3macro_rules! impl_element {
4 ($typ: ident) => {
5 impl Element for $typ {
6
7 fn id(&self) -> Option<&String> {
8 self.id.as_ref()
9 }
10
11 fn set_id<T: Into<String>>(mut self, id: T) -> Self {
12 self.id = Some(id.into());
13 self
14 }
15
16 fn extensions(&self) -> Option<&Vec<Extension>> {
17 self.extension.as_ref()
18 }
19
20 fn set_extensions(mut self, ext: Vec<Extension>) -> Self {
21 self.extension = Some(ext);
22 self
23 }
24
25 fn add_extension(mut self, ext: Extension) -> Self {
26 match self.extension {
27 Some(ref mut exts) => exts.push(ext),
28 None => self.extension = Some(vec![ext]),
29 }
30 self
31 }
32 }
33
34 impl Base for $typ {
35 fn type_name(&self) -> &str {
36 stringify!($typ)
37 }
38 }
39 };
40}