MCPcopy Create free account
hub / github.com/bitflags/bitflags / case

Function case

src/tests/remove.rs:41–100  ·  view source on GitHub ↗
(
    value: T,
    inputs: &[(T, T::Bits)],
    mut inherent_remove: impl FnMut(&mut T, T),
    mut inherent_set: impl FnMut(&mut T, T, bool),
)

Source from the content-addressed store, hash-verified

39
40#[track_caller]
41fn case<T: Flags + std::fmt::Debug + Copy>(
42 value: T,
43 inputs: &[(T, T::Bits)],
44 mut inherent_remove: impl FnMut(&mut T, T),
45 mut inherent_set: impl FnMut(&mut T, T, bool),
46) where
47 T::Bits: std::fmt::Debug + PartialEq + Copy,
48{
49 for (input, expected) in inputs {
50 assert_eq!(
51 *expected,
52 {
53 let mut value = value;
54 inherent_remove(&mut value, *input);
55 value
56 }
57 .bits(),
58 "{:?}.remove({:?})",
59 value,
60 input
61 );
62 assert_eq!(
63 *expected,
64 {
65 let mut value = value;
66 Flags::remove(&mut value, *input);
67 value
68 }
69 .bits(),
70 "Flags::remove({:?}, {:?})",
71 value,
72 input
73 );
74
75 assert_eq!(
76 *expected,
77 {
78 let mut value = value;
79 inherent_set(&mut value, *input, false);
80 value
81 }
82 .bits(),
83 "{:?}.set({:?}, false)",
84 value,
85 input
86 );
87 assert_eq!(
88 *expected,
89 {
90 let mut value = value;
91 Flags::set(&mut value, *input, false);
92 value
93 }
94 .bits(),
95 "Flags::set({:?}, {:?}, false)",
96 value,
97 input
98 );

Callers 1

casesFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected