fn seal(&mut self) -> Result<(), Backend::WriteError> {
        if self.state.range.get() == State::max_value() {
            // This condition only holds upon initialization because encoding a symbol first
            // reduces `range` and then only (possibly) right-shifts it, which introduces
            // some zero bits. We treat this case special and don't emit any words, so that
            // an empty sequence of symbols gets encoded to an empty sequence of words.
            return Ok(());
        }

        let point = self
            .state
            .lower
            .wrapping_add(&((State::one() << (State::BITS - Word::BITS)) - State::one()));

        if let EncoderSituation::Inverted(num_inverted, first_inverted_lower_word) = self.situation
        {
            let (first_word, consecutive_words) = if point < self.state.lower {
                // Unlikely case (addition has wrapped).
                (first_inverted_lower_word + Word::one(), Word::zero())
            } else {
                // Likely case.
                (first_inverted_lower_word, Word::max_value())
            };

            self.bulk.write(first_word)?;
            for _ in 1..num_inverted.get() {
                self.bulk.write(consecutive_words)?;
            }
        }

        let point_word = (point >> (State::BITS - Word::BITS)).as_();
        self.bulk.write(point_word)?;

        let upper_word = (self.state.lower.wrapping_add(&self.state.range.get())
            >> (State::BITS - Word::BITS))
            .as_();
        if upper_word == point_word {
            self.bulk.write(Word::zero())?;
        }

        Ok(())
    }
/// Private method; flushes held-back words if in inverted situation and adds one or two
/// additional words that identify the range regardless of what the compressed data may
/// be concatenated with (unless no symbols have been encoded yet, in which case this is
/// a no-op).
///
/// Doesn't change `self.state` or `self.situation` so that this operation can be
/// reversed if the backend supports removing words (see method `unseal`);
Private method; flushes held-back words if in inverted situation and adds one or two
additional words that identify the range regardless of what the compressed data may
be concatenated with (unless no symbols have been encoded yet, in which case this is
a no-op).

Doesn't change `self.state` or `self.situation` so that this operation can be
reversed if the backend supports removing words .
Private method ; flushes held - back words if in inverted situation and adds one or two additional words that identify the range regardless of what the compressed data may be concatenated with ( unless no symbols have been encoded yet in which case this is a no - op ) . Doesn ' t change ` self . state ` or ` self . situation ` so that this operation can be reversed if the backend supports removing words .
fn seal(&mut self) -> Result<(), Backend::WriteError> {
        if self.state.range.get() == State::max_value() {
            // This condition only holds upon initialization because encoding a symbol first
            // reduces `range` and then only (possibly) right-shifts it, which introduces
            // some zero bits. We treat this case special and don't emit any words, so that
            // an empty sequence of symbols gets encoded to an empty sequence of words.
            return Ok(());
        }
        let point = self
            .state
            .lower
            .wrapping_add(&((State::one() << (State::BITS - Word::BITS)) - State::one()));
        if let EncoderSituation::Inverted(num_inverted, first_inverted_lower_word) = self.situation
        {
            let (first_word, consecutive_words) = if point < self.state.lower {
                // Unlikely case (addition has wrapped).
                (first_inverted_lower_word + Word::one(), Word::zero())
            } else {
                // Likely case.
                (first_inverted_lower_word, Word::max_value())
            };
            self.bulk.write(first_word)?;
            for _ in 1..num_inverted.get() {
                self.bulk.write(consecutive_words)?;
            }
        }
        let point_word = (point >> (State::BITS - Word::BITS)).as_();
        self.bulk.write(point_word)?;
        let upper_word = (self.state.lower.wrapping_add(&self.state.range.get())
            >> (State::BITS - Word::BITS))
            .as_();
        if upper_word == point_word {
            self.bulk.write(Word::zero())?;
        }
        Ok(())
    }
fn seal ( & mut self ) -> Result < ( ) , Backend :: WriteError > { if self . state . range . get ( ) == State :: max_value ( ) { // This condition only holds upon initialization because encoding a symbol first // reduces `range` and then only (possibly) right-shifts it, which introduces // some zero bits. We treat this case special and don't emit any words, so that // an empty sequence of symbols gets encoded to an empty sequence of words. return Ok ( ( ) ) ; } let point = self . state . lower . wrapping_add ( & ( ( State :: one ( ) << ( State :: BITS - Word :: BITS ) ) - State :: one ( ) ) ) ; if let EncoderSituation :: Inverted ( num_inverted , first_inverted_lower_word ) = self . situation { let ( first_word , consecutive_words ) = if point < self . state . lower { // Unlikely case (addition has wrapped). ( first_inverted_lower_word + Word :: one ( ) , Word :: zero ( ) ) } else { // Likely case. ( first_inverted_lower_word , Word :: max_value ( ) ) } ; self . bulk . write ( first_word ) ? ; for _ in 1 .. num_inverted . get ( ) { self . bulk . write ( consecutive_words ) ? ; } } let point_word = ( point >> ( State :: BITS - Word :: BITS ) ) . as_ ( ) ; self . bulk . write ( point_word ) ? ; let upper_word = ( self . state . lower . wrapping_add ( & self . state . range . get ( ) ) >> ( State :: BITS - Word :: BITS ) ) . as_ ( ) ; if upper_word == point_word { self . bulk . write ( Word :: zero ( ) ) ? ; } Ok ( ( ) ) }
Private method; flushes held-back words if in inverted situation and adds one or two
additional words that identify the range regardless of what the compressed data may
be concatenated with (unless no symbols have been encoded yet, in which case this is
a no-op).
Private method ; flushes held - back words if in inverted situation and adds one or two additional words that identify the range regardless of what the compressed data may be concatenated with ( unless no symbols have been encoded yet in which case this is a no - op ) .
&mut self
&mut self