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

Function case

src/tests/union.rs:29–71  ·  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

27
28#[track_caller]
29fn case<T: Flags + std::fmt::Debug + std::ops::BitOr<Output = T> + std::ops::BitOrAssign + Copy>(
30 value: T,
31 inputs: &[(T, T::Bits)],
32 mut inherent: impl FnMut(T, T) -> T,
33) where
34 T::Bits: std::fmt::Debug + PartialEq + Copy,
35{
36 for (input, expected) in inputs {
37 assert_eq!(
38 *expected,
39 inherent(value, *input).bits(),
40 "{:?}.union({:?})",
41 value,
42 input
43 );
44 assert_eq!(
45 *expected,
46 Flags::union(value, *input).bits(),
47 "Flags::union({:?}, {:?})",
48 value,
49 input
50 );
51 assert_eq!(
52 *expected,
53 (value | *input).bits(),
54 "{:?} | {:?}",
55 value,
56 input
57 );
58 assert_eq!(
59 *expected,
60 {
61 let mut value = value;
62 value |= *input;
63 value
64 }
65 .bits(),
66 "{:?} |= {:?}",
67 value,
68 input,
69 );
70 }
71}

Callers 1

casesFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected