From a990de90fe41456a23e58bd087d2f107d321f3a1 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Fri, 19 Jul 2024 16:37:58 +0400 Subject: Deleted vendor folder --- vendor/bitflags/examples/macro_free.rs | 61 ---------------------------------- 1 file changed, 61 deletions(-) delete mode 100644 vendor/bitflags/examples/macro_free.rs (limited to 'vendor/bitflags/examples/macro_free.rs') diff --git a/vendor/bitflags/examples/macro_free.rs b/vendor/bitflags/examples/macro_free.rs deleted file mode 100644 index 7563379..0000000 --- a/vendor/bitflags/examples/macro_free.rs +++ /dev/null @@ -1,61 +0,0 @@ -//! An example of implementing the `BitFlags` trait manually for a flags type. -//! -//! This example doesn't use any macros. - -use std::{fmt, str}; - -use bitflags::{Flag, Flags}; - -// First: Define your flags type. It just needs to be `Sized + 'static`. -pub struct ManualFlags(u32); - -// Not required: Define some constants for valid flags -impl ManualFlags { - pub const A: ManualFlags = ManualFlags(0b00000001); - pub const B: ManualFlags = ManualFlags(0b00000010); - pub const C: ManualFlags = ManualFlags(0b00000100); - pub const ABC: ManualFlags = ManualFlags(0b00000111); -} - -// Next: Implement the `BitFlags` trait, specifying your set of valid flags -// and iterators -impl Flags for ManualFlags { - const FLAGS: &'static [Flag] = &[ - Flag::new("A", Self::A), - Flag::new("B", Self::B), - Flag::new("C", Self::C), - ]; - - type Bits = u32; - - fn bits(&self) -> u32 { - self.0 - } - - fn from_bits_retain(bits: u32) -> Self { - Self(bits) - } -} - -// Not required: Add parsing support -impl str::FromStr for ManualFlags { - type Err = bitflags::parser::ParseError; - - fn from_str(input: &str) -> Result { - bitflags::parser::from_str(input) - } -} - -// Not required: Add formatting support -impl fmt::Display for ManualFlags { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - bitflags::parser::to_writer(self, f) - } -} - -fn main() { - println!( - "{}", - ManualFlags::A.union(ManualFlags::B).union(ManualFlags::C) - ); -} -- cgit v1.2.3