Skip to content

Commit

Permalink
write doc for set_bit
Browse files Browse the repository at this point in the history
  • Loading branch information
krakow10 committed Sep 5, 2024
1 parent 0c33e0d commit 054250f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/buint/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
16 changes: 16 additions & 0 deletions src/doc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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! {
Expand Down

0 comments on commit 054250f

Please sign in to comment.