pub fn resize_to(&self, new_bits_per_value: u8) -> Result<BitArray, ()> {
        assert!(
            new_bits_per_value <= 64,
            "Bits per value cannot be more than 64"
        );

        let mut new_arr = BitArray::new(new_bits_per_value, self.capacity);

        for i in 0..self.capacity {
            let val = self.get(i);
            if needed_bits(val) > new_bits_per_value {
                return Err(());
            }

            new_arr.set(i, val);
            debug_assert_eq!(new_arr.get(i), val);
        }

        Ok(new_arr)
    }
/// Produces a `BitArray` with the same values
/// as this `BitArray` but with a new bits per value.
/// If a value in this `BitArray` cannot be represented
/// by the new bits per value, `Err` is returned.
Produces a `BitArray` with the same values
as this `BitArray` but with a new bits per value.
If a value in this `BitArray` cannot be represented
by the new bits per value, `Err` is returned.
Produces a ` BitArray ` with the same values as this ` BitArray ` but with a new bits per value . If a value in this ` BitArray ` cannot be represented by the new bits per value ` Err ` is returned .
pub fn resize_to(&self, new_bits_per_value: u8) -> Result<BitArray, ()> {
        assert!(
            new_bits_per_value <= 64,
            "Bits per value cannot be more than 64"
        );
        let mut new_arr = BitArray::new(new_bits_per_value, self.capacity);
        for i in 0..self.capacity {
            let val = self.get(i);
            if needed_bits(val) > new_bits_per_value {
                return Err(());
            }
            new_arr.set(i, val);
            debug_assert_eq!(new_arr.get(i), val);
        }
        Ok(new_arr)
    }
pub fn resize_to ( & self , new_bits_per_value : u8 ) -> Result < BitArray , ( ) > { assert ! ( new_bits_per_value 64 " " ) ; let mut new_arr = BitArray :: new ( new_bits_per_value , self . capacity ) ; for i in 0 .. self . capacity { let val = self . get ( i ) ; if needed_bits ( val ) > new_bits_per_value { return Err ( ( ) ) ; } new_arr . set ( i , val ) ; debug_assert_eq ! ( new_arr get ( i ) val ) ; } Ok ( new_arr ) }
Produces a `BitArray` with the same values
as this `BitArray` but with a new bits per value.
Produces a ` BitArray ` with the same values as this ` BitArray ` but with a new bits per value .
&self
new_bits_per_value
u8
&self
new_bits_per_value
u8