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

Function case

src/tests/intersection.rs:37–79  ·  view source on GitHub ↗
(
    value: T,
    inputs: &[(T, T::Bits)],
    mut inherent: impl FnMut(T, T) -> T,
)

Source from the content-addressed store, hash-verified

35
36#[track_caller]
37fn case<T: Flags + std::fmt::Debug + std::ops::BitAnd<Output = T> + std::ops::BitAndAssign + Copy>(
38 value: T,
39 inputs: &[(T, T::Bits)],
40 mut inherent: impl FnMut(T, T) -> T,
41) where
42 T::Bits: std::fmt::Debug + PartialEq + Copy,
43{
44 for (input, expected) in inputs {
45 assert_eq!(
46 *expected,
47 inherent(value, *input).bits(),
48 "{:?}.intersection({:?})",
49 value,
50 input
51 );
52 assert_eq!(
53 *expected,
54 Flags::intersection(value, *input).bits(),
55 "Flags::intersection({:?}, {:?})",
56 value,
57 input
58 );
59 assert_eq!(
60 *expected,
61 (value & *input).bits(),
62 "{:?} & {:?}",
63 value,
64 input
65 );
66 assert_eq!(
67 *expected,
68 {
69 let mut value = value;
70 value &= *input;
71 value
72 }
73 .bits(),
74 "{:?} &= {:?}",
75 value,
76 input,
77 );
78 }
79}

Callers 1

casesFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected