fn with_leading(mut self, leading: PositionedTrivia) -> Self {
        let mut token = RcOc::make_mut(&mut self);
        let token_start_offset = token.offset + token.leading_width;
        let leading_width = leading.iter().map(|x| x.width).sum();
        token.offset = token_start_offset - leading_width;
        token.leading_width = leading_width;
        token.leading = leading;
        self
    }
// Tricky: the with_ functions that modify tokens can be very cheap (when ref count is 1), or
// possibly expensive (when make_mut has to perform a clone of underlying token that is shared).
// Fortunately, they are used only in lexer/parser BEFORE the tokens are embedded in syntax, so
// before any sharing occurs
the with_ functions that modify tokens can be very cheap (when ref count is 1), or
possibly expensive (when make_mut has to perform a clone of underlying token that is shared).
Fortunately, they are used only in lexer/parser BEFORE the tokens are embedded in syntax, so
before any sharing occurs
the with_ functions that modify tokens can be very cheap ( when ref count is 1 ) or possibly expensive ( when make_mut has to perform a clone of underlying token that is shared ) . Fortunately they are used only in lexer / parser BEFORE the tokens are embedded in syntax so before any sharing occurs
fn with_leading(mut self, leading: PositionedTrivia) -> Self {
        let mut token = RcOc::make_mut(&mut self);
        let token_start_offset = token.offset + token.leading_width;
        let leading_width = leading.iter().map(|x| x.width).sum();
        token.offset = token_start_offset - leading_width;
        token.leading_width = leading_width;
        token.leading = leading;
        self
    }
fn with_leading ( mut self , leading : PositionedTrivia ) -> Self { let mut token = RcOc :: make_mut ( & mut self ) ; let token_start_offset = token . offset + token . leading_width ; let leading_width = leading . iter ( ) . map ( | x | x . width ) . sum ( ) ; token . offset = token_start_offset - leading_width ; token . leading_width = leading_width ; token . leading = leading ; self }
Tricky: the with_ functions that modify tokens can be very cheap (when ref count is 1), or
possibly expensive (when make_mut has to perform a clone of underlying token that is shared).
Tricky : the with_ functions that modify tokens can be very cheap ( when ref count is 1 ) or possibly expensive ( when make_mut has to perform a clone of underlying token that is shared ) .
mut self
leading
PositionedTrivia
mut self
leading
PositionedTrivia