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
#[derive(Debug)]
pub struct Domain<'a> {
pub subdomain: Option<&'a str>,
pub domain: Option<&'a str>,
pub top_level_domain: Option<&'a str>,
}
impl<'a> PartialEq for Domain<'a> {
fn eq(&self, other: &Self) -> bool {
self.subdomain == other.subdomain && self.domain == other.domain
}
}
impl<'a> Domain<'a> {
pub fn empty() -> Domain<'a> {
Domain {
subdomain: None,
domain: None,
top_level_domain: None,
}
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_domain_empty_when_typical() {
let expected = Domain {
subdomain: None,
domain: None,
top_level_domain: None,
};
let result = Domain::empty();
assert_eq!(result, expected);
}
}