pub struct LineBuffer { /* private fields */ }
Expand description

Abstraction over a string to handle manipulation operations at char boundaries.

This exists because Rust strings are indexed by bytes and manipulating string bytes is complicated.

TODO(zenria): The current implementation of the buffer is using String::chars. Should be converted to using graphemes instead.

Implementations§

Creates an empty LineBuffer with an allocated capacity.

Returns the logical LineBuffer length (in UTF-8 code point count and not in bytes).

Gets and iterator over buffer chars.

Returns the end of the string starting at start_pos, or an empty string if start_pos is after the string’s end.

Returns the characters from the start of the string to end_pos, excluding end_pos.

Calling this with end_pos set to 0 will return an empty string, and a 1-char string if end_pos is 1 (if the string contains at least 1 character).

Extracts a range of characters from this buffer.

Checks if this buffer is empty or not.

Gets a view on the underlying bytes held by this buffer.

Warning: direct bytes manipulation may lead to undefined behavior.

Removes a character from this buffer.

If the given position if greater than the length of the buffer, this function does nothing.

Inserts a char at the given position.

If the position is greater than the buffer length, the character will be appended at the end ot it.

Returns the underlying string.

Inserts the given string s into the buffer at pos.

If pos is greater than the length of the buffer, s will be appended at the end of it.

Appends the given string s to the buffer.

Splits the buffer in two parts at the position at.

Returns the remaining part of the buffer (same behavior as String::split_off).

Trait Implementations§

Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more
Formats the value using the given formatter. Read more
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Converts the given value to a String. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.