pub unsafe fn try_from_trusted_len_iter_unchecked<E, I>(
        mut iterator: I,
    ) -> std::result::Result<Self, E>
    where
        I: Iterator<Item = std::result::Result<bool, E>>,
    {
        let length = iterator.size_hint().1.unwrap();

        let mut buffer = vec![0u8; (length + 7) / 8];

        let chunks = length / 8;
        let reminder = length % 8;

        let data = buffer.as_mut_slice();
        data[..chunks].iter_mut().try_for_each(|byte| {
            (0..8).try_for_each(|i| {
                *byte = set(*byte, i, iterator.next().unwrap()?);
                Ok(())
            })
        })?;

        if reminder != 0 {
            let last = &mut data[chunks];
            iterator.enumerate().try_for_each(|(i, value)| {
                *last = set(*last, i, value?);
                Ok(())
            })?;
        }

        Ok(Self { buffer, length })
    }
/// Creates a new [`MutableBitmap`] from an falible iterator of booleans.
/// # Safety
/// The caller must guarantee that the iterator is `TrustedLen`.
Creates a new [`MutableBitmap`] from an falible iterator of booleans.
Creates a new [ ` MutableBitmap ` ] from an falible iterator of booleans .
pub unsafe fn try_from_trusted_len_iter_unchecked<E, I>(
        mut iterator: I,
    ) -> std::result::Result<Self, E>
    where
        I: Iterator<Item = std::result::Result<bool, E>>,
    {
        let length = iterator.size_hint().1.unwrap();
        let mut buffer = vec![0u8; (length + 7) / 8];
        let chunks = length / 8;
        let reminder = length % 8;
        let data = buffer.as_mut_slice();
        data[..chunks].iter_mut().try_for_each(|byte| {
            (0..8).try_for_each(|i| {
                *byte = set(*byte, i, iterator.next().unwrap()?);
                Ok(())
            })
        })?;
        if reminder != 0 {
            let last = &mut data[chunks];
            iterator.enumerate().try_for_each(|(i, value)| {
                *last = set(*last, i, value?);
                Ok(())
            })?;
        }
        Ok(Self { buffer, length })
    }
pub unsafe fn try_from_trusted_len_iter_unchecked < E , I > ( mut iterator : I , ) -> std :: result :: Result < Self , E > where I : Iterator < Item = std :: result :: Result < bool , E > > , { let length = iterator . size_hint ( ) . 1 . unwrap ( ) ; let mut buffer = vec ! [ 0u8 ( length 7 ) 8 ] ; let chunks = length / 8 ; let reminder = length % 8 ; let data = buffer . as_mut_slice ( ) ; data [ .. chunks ] . iter_mut ( ) . try_for_each ( | byte | { ( 0 .. 8 ) . try_for_each ( | i | { * byte = set ( * byte , i , iterator . next ( ) . unwrap ( ) ? ) ; Ok ( ( ) ) } ) } ) ? ; if reminder != 0 { let last = & mut data [ chunks ] ; iterator . enumerate ( ) . try_for_each ( | ( i , value ) | { * last = set ( * last , i , value ? ) ; Ok ( ( ) ) } ) ? ; } Ok ( Self { buffer , length } ) }
Creates a new [`MutableBitmap`] from an falible iterator of booleans.
Creates a new [ ` MutableBitmap ` ] from an falible iterator of booleans .
iterator
I
iterator
I
safety
The caller must guarantee that the iterator is `TrustedLen`.
The caller must guarantee that the iterator is ` TrustedLen ` .