Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aienux/blob/main/vendor/bitflags/src/external/arbitrary.rs # aienux Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aienux / vendor / bitflags / src / external / arbitrary.rs` 33 lines ยท 779 bytes Raw Blame History 1 //! Specialized fuzzing for flags types using `arbitrary`. 2 3 use crate::Flags; 4 5 /** 6 Generate some arbitrary flags value with only known bits set. 7 */ 8 pub fn arbitrary<'a, B: Flags>(u: &mut arbitrary::Unstructured<'a>) -> arbitrary::Result 9 where 10 B::Bits: arbitrary::Arbitrary<'a>, 11 { 12 B::from_bits(u.arbitrary()?).ok_or(arbitrary::Error::IncorrectFormat) 13 } 14 15 #[cfg(test)] 16 mod tests { 17 use arbitrary::Arbitrary; 18 19 bitflags! { 20 #[derive(Arbitrary)] 21 struct Color: u32 { 22 const RED = 0x1; 23 const GREEN = 0x2; 24 const BLUE = 0x4; 25 } 26 } 27 28 #[test] 29 fn test_arbitrary() { 30 let mut unstructured = arbitrary::Unstructured::new(&[0_u8; 256]); 31 let _color = Color::arbitrary(&mut unstructured); 32 } 33 }