Apply a bitwise binary operation to `self`. If the underlying buffer is uniquely owned, reuses the allocation and updates the bytes in place. If the underlying buffer is shared, returns a newly allocated buffer. # API Notes If the buffer is reused, the result preserves the existing offset, which may be non-zero.
(&mut self, rhs: &BooleanBuffer, op: F)
| 574 | /// If the buffer is reused, the result preserves the existing offset, which |
| 575 | /// may be non-zero. |
| 576 | fn bitwise_bin_op_assign<F>(&mut self, rhs: &BooleanBuffer, op: F) |
| 577 | where |
| 578 | F: FnMut(u64, u64) -> u64, |
| 579 | { |
| 580 | assert_eq!(self.bit_len, rhs.bit_len); |
| 581 | // Try to mutate in place if the buffer is uniquely owned |
| 582 | let buffer = std::mem::take(&mut self.buffer); |
| 583 | match buffer.into_mutable() { |
| 584 | Ok(mut buf) => { |
| 585 | bit_util::apply_bitwise_binary_op( |
| 586 | &mut buf, |
| 587 | self.bit_offset, |
| 588 | &rhs.buffer, |
| 589 | rhs.bit_offset, |
| 590 | self.bit_len, |
| 591 | op, |
| 592 | ); |
| 593 | self.buffer = buf.into(); |
| 594 | } |
| 595 | Err(buf) => { |
| 596 | self.buffer = buf; |
| 597 | *self = BooleanBuffer::from_bitwise_binary_op( |
| 598 | self.values(), |
| 599 | self.bit_offset, |
| 600 | rhs.values(), |
| 601 | rhs.bit_offset, |
| 602 | self.bit_len, |
| 603 | op, |
| 604 | ); |
| 605 | } |
| 606 | } |
| 607 | } |
| 608 | |
| 609 | /// Returns an iterator over the bits in this [`BooleanBuffer`] |
| 610 | pub fn iter(&self) -> BitIterator<'_> { |
no test coverage detected