1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
//! A library for working with small and cheap bit sets and masks //! //! Masks keep track of usize indexes which are set through //! [testing][Mask::test]. This allows for masking indexes in certain //! operations. Like if you want to mask which channels in an audio buffer is in //! use or not. //! //! # Examples //! //! ```rust //! fn test<M>(mask: M) where M: bittle::Mask { //! assert!(!mask.test(0)); //! assert!(mask.test(1)); //! } //! //! let mut set = bittle::BitSet::<u16>::empty(); //! set.set(1); //! //! test(&set); //! //! set.clear(1); //! //! assert_eq!(std::mem::size_of_val(&set), std::mem::size_of::<u16>()); //! ``` #[macro_use] mod macros; mod mask; pub use self::mask::Mask; mod bit_set; pub use self::bit_set::BitSet; /// Construct the special mask where every index is set. /// /// # Examples /// /// ```rust /// use bittle::Mask; /// /// let n = bittle::all(); /// /// assert!(n.test(0)); /// assert!(n.test(usize::MAX)); /// ``` pub fn all() -> self::mask::All { self::mask::all::All::default() } /// Construct the special mask where no index is set. /// /// # Examples /// /// ```rust /// use bittle::Mask; /// /// let n = bittle::none(); /// /// assert!(!n.test(0)); /// assert!(!n.test(usize::MAX)); /// ``` pub fn none() -> self::mask::None { self::mask::none::None::default() }