yew_nav_link/active_link/
mode.rs1#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
3#[must_use]
4pub enum Match {
5 #[default]
7 Exact,
8 Partial
10}
11
12impl std::fmt::Display for Match {
13 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
14 match self {
15 Self::Exact => write!(f, "exact"),
16 Self::Partial => write!(f, "partial")
17 }
18 }
19}
20
21#[cfg(test)]
22mod tests {
23 use super::*;
24
25 #[test]
26 fn match_default_is_exact() {
27 assert_eq!(Match::default(), Match::Exact);
28 }
29
30 #[test]
31 fn match_equality() {
32 assert_eq!(Match::Exact, Match::Exact);
33 assert_eq!(Match::Partial, Match::Partial);
34 assert_ne!(Match::Exact, Match::Partial);
35 }
36
37 #[test]
38 fn match_debug() {
39 assert_eq!(format!("{:?}", Match::Exact), "Exact");
40 }
41
42 #[test]
43 fn match_clone() {
44 let m = Match::Partial;
45 let cloned = m;
46 assert_eq!(m, cloned);
47 }
48
49 #[test]
50 fn match_display() {
51 assert_eq!(format!("{}", Match::Exact), "exact");
52 assert_eq!(format!("{}", Match::Partial), "partial");
53 }
54
55 #[test]
56 fn match_copy() {
57 let m = Match::Exact;
58 let copied = m;
59 assert_eq!(m, copied);
60 }
61}