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