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

Function case

src/tests/insert.rs:32–91  ·  view source on GitHub ↗
(
    value: T,
    inputs: &[(T, T::Bits)],
    mut inherent_insert: impl FnMut(&mut T, T),
    mut inherent_set: impl FnMut(&mut T, T, bool),
)

Source from the content-addressed store, hash-verified

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

Callers 1

casesFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected