diff --git a/src/buint/mod.rs b/src/buint/mod.rs index c45289f..7a6c7f1 100644 --- a/src/buint/mod.rs +++ b/src/buint/mod.rs @@ -455,7 +455,7 @@ macro_rules! mod_impl { digit & (1 << (index & digit::$Digit::BITS_MINUS_1)) != 0 } - #[doc = doc::bit!(U 256)] + #[doc = doc::set_bit!(U 256)] #[must_use] #[inline] pub fn set_bit(&mut self, index: ExpType, value: bool) { diff --git a/src/doc/mod.rs b/src/doc/mod.rs index 333869d..ba1b356 100644 --- a/src/doc/mod.rs +++ b/src/doc/mod.rs @@ -345,6 +345,22 @@ macro_rules! bit { pub(crate) use bit; +macro_rules! set_bit { + ($sign: ident $bits: literal) => { + doc::doc_comment! { + $sign $bits, + "Sets/unsets the bit in the given position (`1` if value is true). The least significant bit is at index `0`, the most significant bit is at index `Self::BITS - 1`", + + "let mut n = " doc::type_str!($sign $bits) "::from(0b001010100101010101u32);\n" + "assert!(n.bit(2));\n" + "n.set_bit(2,false);\n" + "assert!(!n.bit(2));\n" + } + }; +} + +pub(crate) use set_bit; + macro_rules! is_zero { ($sign: ident $bits: literal) => { doc::doc_comment! {