pub fn with_capacity(capacity: usize) -> Self {
		Self::assert_len_encodable(capacity);
		let mut vec = capacity
			.pipe(crate::mem::elts::<T>)
			.pipe(Vec::<T>::with_capacity)
			.pipe(ManuallyDrop::new);
		let (addr, capacity) = (vec.as_mut_ptr(), vec.capacity());
		let bitspan = BitSpan::uninhabited(unsafe { addr.into_address() });
		Self { bitspan, capacity }
	}
/// Allocates a new, empty, bit-vector with space for at least `capacity`
/// bits before reallocating.
///
/// ## Original
///
/// [`Vec::with_capacity`](alloc::vec::Vec::with_capacity)
///
/// ## Panics
///
/// This panics if the requested capacity is longer than what the bit-vector
/// can represent. See [`BitSlice::MAX_BITS`].
///
/// ## Examples
///
/// ```rust
/// use bitvec::prelude::*;
///
/// let mut bv: BitVec = BitVec::with_capacity(128);
///
/// assert!(bv.is_empty());
/// assert!(bv.capacity() >= 128);
///
/// for i in 0 .. 128 {
///   bv.push(i & 0xC0 == i);
/// }
/// assert_eq!(bv.len(), 128);
/// assert!(bv.capacity() >= 128);
///
/// bv.push(false);
/// assert_eq!(bv.len(), 129);
/// assert!(bv.capacity() >= 129);
/// ```
///
/// [`BitSlice::MAX_BITS`]: crate::slice::BitSlice::MAX_BITS
Allocates a new, empty, bit-vector with space for at least `capacity`
bits before reallocating.
Allocates a new empty bit - vector with space for at least ` capacity ` bits before reallocating .
pub fn with_capacity(capacity: usize) -> Self {
		Self::assert_len_encodable(capacity);
		let mut vec = capacity
			.pipe(crate::mem::elts::<T>)
			.pipe(Vec::<T>::with_capacity)
			.pipe(ManuallyDrop::new);
		let (addr, capacity) = (vec.as_mut_ptr(), vec.capacity());
		let bitspan = BitSpan::uninhabited(unsafe { addr.into_address() });
		Self { bitspan, capacity }
	}
pub fn with_capacity ( capacity : usize ) -> Self { Self :: assert_len_encodable ( capacity ) ; let mut vec = capacity . pipe ( crate :: mem :: elts :: < T > ) . pipe ( Vec :: < T > :: with_capacity ) . pipe ( ManuallyDrop :: new ) ; let ( addr , capacity ) = ( vec . as_mut_ptr ( ) , vec . capacity ( ) ) ; let bitspan = BitSpan :: uninhabited ( unsafe { addr . into_address ( ) } ) ; Self { bitspan , capacity } }
Allocates a new, empty, bit-vector with space for at least `capacity`
bits before reallocating.
Allocates a new empty bit - vector with space for at least ` capacity ` bits before reallocating .
capacity
usize
capacity
usize
original
None
panics
This panics if the requested capacity is longer than what the bit-vector
can represent. See [`BitSlice::MAX_BITS`].
This panics if the requested capacity is longer than what the bit - vector can represent . See [ ` BitSlice :: MAX_BITS ` ] .
examples
```rust
use bitvec::prelude::*.

let mut bv: BitVec = BitVec::with_capacity(128).



for i in 0 ..



[`BitSlice::MAX_BITS`]: crate::slice::BitSlice::MAX_BITS
` ` ` rust use bitvec :: prelude :: * . let mut bv : BitVec = BitVec :: with_capacity ( 128 ) . for i in 0 .. [ ` BitSlice :: MAX_BITS ` ] : crate :: slice :: BitSlice :: MAX_BITS