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/src/external/arbitrary.rs | 33 ----------- vendor/bitflags/src/external/bytemuck.rs | 19 ------- vendor/bitflags/src/external/serde.rs | 93 ------------------------------- 3 files changed, 145 deletions(-) delete mode 100644 vendor/bitflags/src/external/arbitrary.rs delete mode 100644 vendor/bitflags/src/external/bytemuck.rs delete mode 100644 vendor/bitflags/src/external/serde.rs (limited to 'vendor/bitflags/src/external') diff --git a/vendor/bitflags/src/external/arbitrary.rs b/vendor/bitflags/src/external/arbitrary.rs deleted file mode 100644 index ea76f0a..0000000 --- a/vendor/bitflags/src/external/arbitrary.rs +++ /dev/null @@ -1,33 +0,0 @@ -//! Specialized fuzzing for flags types using `arbitrary`. - -use crate::Flags; - -/** -Generate some arbitrary flags value with only known bits set. -*/ -pub fn arbitrary<'a, B: Flags>(u: &mut arbitrary::Unstructured<'a>) -> arbitrary::Result -where - B::Bits: arbitrary::Arbitrary<'a>, -{ - B::from_bits(u.arbitrary()?).ok_or_else(|| arbitrary::Error::IncorrectFormat) -} - -#[cfg(test)] -mod tests { - use arbitrary::Arbitrary; - - bitflags! { - #[derive(Arbitrary)] - struct Color: u32 { - const RED = 0x1; - const GREEN = 0x2; - const BLUE = 0x4; - } - } - - #[test] - fn test_arbitrary() { - let mut unstructured = arbitrary::Unstructured::new(&[0_u8; 256]); - let _color = Color::arbitrary(&mut unstructured); - } -} diff --git a/vendor/bitflags/src/external/bytemuck.rs b/vendor/bitflags/src/external/bytemuck.rs deleted file mode 100644 index a0cd68c..0000000 --- a/vendor/bitflags/src/external/bytemuck.rs +++ /dev/null @@ -1,19 +0,0 @@ -#[cfg(test)] -mod tests { - use bytemuck::{Pod, Zeroable}; - - bitflags! { - #[derive(Pod, Zeroable, Clone, Copy)] - #[repr(transparent)] - struct Color: u32 { - const RED = 0x1; - const GREEN = 0x2; - const BLUE = 0x4; - } - } - - #[test] - fn test_bytemuck() { - assert_eq!(0x1, bytemuck::cast::(Color::RED)); - } -} diff --git a/vendor/bitflags/src/external/serde.rs b/vendor/bitflags/src/external/serde.rs deleted file mode 100644 index be4f2ed..0000000 --- a/vendor/bitflags/src/external/serde.rs +++ /dev/null @@ -1,93 +0,0 @@ -//! Specialized serialization for flags types using `serde`. - -use crate::{ - parser::{self, ParseHex, WriteHex}, - Flags, -}; -use core::{fmt, str}; -use serde::{ - de::{Error, Visitor}, - Deserialize, Deserializer, Serialize, Serializer, -}; - -/** -Serialize a set of flags as a human-readable string or their underlying bits. - -Any unknown bits will be retained. -*/ -pub fn serialize(flags: &B, serializer: S) -> Result -where - B::Bits: WriteHex + Serialize, -{ - // Serialize human-readable flags as a string like `"A | B"` - if serializer.is_human_readable() { - serializer.collect_str(&parser::AsDisplay(flags)) - } - // Serialize non-human-readable flags directly as the underlying bits - else { - flags.bits().serialize(serializer) - } -} - -/** -Deserialize a set of flags from a human-readable string or their underlying bits. - -Any unknown bits will be retained. -*/ -pub fn deserialize<'de, B: Flags, D: Deserializer<'de>>(deserializer: D) -> Result -where - B::Bits: ParseHex + Deserialize<'de>, -{ - if deserializer.is_human_readable() { - // Deserialize human-readable flags by parsing them from strings like `"A | B"` - struct FlagsVisitor(core::marker::PhantomData); - - impl<'de, B: Flags> Visitor<'de> for FlagsVisitor - where - B::Bits: ParseHex, - { - type Value = B; - - fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { - formatter.write_str("a string value of `|` separated flags") - } - - fn visit_str(self, flags: &str) -> Result { - parser::from_str(flags).map_err(|e| E::custom(e)) - } - } - - deserializer.deserialize_str(FlagsVisitor(Default::default())) - } else { - // Deserialize non-human-readable flags directly from the underlying bits - let bits = B::Bits::deserialize(deserializer)?; - - Ok(B::from_bits_retain(bits)) - } -} - -#[cfg(test)] -mod tests { - use serde_test::{assert_tokens, Configure, Token::*}; - bitflags! { - #[derive(serde_derive::Serialize, serde_derive::Deserialize, Debug, PartialEq, Eq)] - #[serde(transparent)] - struct SerdeFlags: u32 { - const A = 1; - const B = 2; - const C = 4; - const D = 8; - } - } - - #[test] - fn test_serde_bitflags_default() { - assert_tokens(&SerdeFlags::empty().readable(), &[Str("")]); - - assert_tokens(&SerdeFlags::empty().compact(), &[U32(0)]); - - assert_tokens(&(SerdeFlags::A | SerdeFlags::B).readable(), &[Str("A | B")]); - - assert_tokens(&(SerdeFlags::A | SerdeFlags::B).compact(), &[U32(1 | 2)]); - } -} -- cgit v1.2.3