1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#[derive(PartialEq, Debug, Clone, RustcEncodable, RustcDecodable)]
pub struct Address {
address1: String,
address2: Option<String>,
city: String,
state: String,
zip: String,
country: String,
}
impl Address {
pub fn new<S: AsRef<str>>(address1: S,
address2: Option<S>,
city: S,
state: S,
zip: S,
country: S)
-> Address {
Address {
address1: address1.as_ref().to_owned(),
address2: match address2 {
Some(s) => Some(s.as_ref().to_owned()),
None => None,
},
city: city.as_ref().to_owned(),
state: state.as_ref().to_owned(),
zip: zip.as_ref().to_owned(),
country: country.as_ref().to_owned(),
}
}
pub fn get_address1(&self) -> &String {
&self.address1
}
pub fn get_address2(&self) -> Option<&String> {
self.address2.as_ref()
}
pub fn get_city(&self) -> &str {
&self.city
}
pub fn get_state(&self) -> &str {
&self.state
}
pub fn get_zip(&self) -> &String {
&self.zip
}
pub fn get_country(&self) -> &String {
&self.country
}
}