pub fn resize_with<F>(&mut self, new_len: usize, mut func: F)
	where F: FnMut(usize) -> bool {
		let old_len = self.len();
		self.resize(new_len, false);
		if new_len > old_len {
			for (bitptr, idx) in unsafe { self.get_unchecked_mut(old_len ..) }
				.as_mut_bitptr_range()
				.zip(old_len ..)
			{
				unsafe {
					bitptr.write(func(idx));
				}
			}
		}
	}
/// Resizes the bit-vector to a new length, using a function to produce each
/// inserted bit.
///
/// If `new_len` is less than `self.len()`, this is a truncate operation; if
/// it is greater, then `self` is extended by repeatedly pushing `func()`.
///
/// ## Original
///
/// [`Vec::resize_with`](alloc::vec::Vec::resize_with)
///
/// ## API Differences
///
/// The generator function receives the index into which its bit will be
/// placed.
///
/// ## Examples
///
/// ```rust
/// use bitvec::prelude::*;
///
/// let mut bv = bitvec![1; 2];
/// bv.resize_with(5, |idx| idx % 2 == 1);
/// assert_eq!(bv, bits![1, 1, 0, 1, 0]);
/// ```
Resizes the bit-vector to a new length, using a function to produce each
inserted bit.


Resizes the bit - vector to a new length using a function to produce each inserted bit .
pub fn resize_with<F>(&mut self, new_len: usize, mut func: F)
	where F: FnMut(usize) -> bool {
		let old_len = self.len();
		self.resize(new_len, false);
		if new_len > old_len {
			for (bitptr, idx) in unsafe { self.get_unchecked_mut(old_len ..) }
				.as_mut_bitptr_range()
				.zip(old_len ..)
			{
				unsafe {
					bitptr.write(func(idx));
				}
			}
		}
	}
pub fn resize_with < F > ( & mut self , new_len : usize , mut func : F ) where F : FnMut ( usize ) -> bool { let old_len = self . len ( ) ; self . resize ( new_len , false ) ; if new_len > old_len { for ( bitptr , idx ) in unsafe { self . get_unchecked_mut ( old_len .. ) } . as_mut_bitptr_range ( ) . zip ( old_len .. ) { unsafe { bitptr . write ( func ( idx ) ) ; } } } }
Resizes the bit-vector to a new length, using a function to produce each
inserted bit.
Resizes the bit - vector to a new length using a function to produce each inserted bit .
&mut self
new_len
usize
func
F
&mut self
new_len
usize
func
F
original
None
api differences
The generator function receives the index into which its bit will be
placed.
The generator function receives the index into which its bit will be placed .
examples
```rust
use bitvec::prelude::*.


` ` ` rust use bitvec :: prelude :: * .