pub trait TextBuffer: AsRef<str> {
    fn is_mutable(&self) -> bool;
    fn insert_text(&mut self, text: &str, char_index: usize) -> usize;
    fn delete_char_range(&mut self, char_range: Range<usize>);

    fn as_str(&self) -> &str { ... }
    fn char_range(&self, char_range: Range<usize>) -> &str { ... }
    fn byte_index_from_char_index(&self, char_index: usize) -> usize { ... }
    fn clear(&mut self) { ... }
    fn replace(&mut self, text: &str) { ... }
    fn take(&mut self) -> String { ... }
}
Expand description

Trait constraining what types crate::TextEdit may use as an underlying buffer.

Most likely you will use a String which implements TextBuffer.

Required Methods

Can this text be edited?

Inserts text text into this buffer at character index char_index.

Notes

char_index is a character index, not a byte index.

Return

Returns how many characters were successfully inserted

Deletes a range of text char_range from this buffer.

Notes

char_range is a character range, not a byte range.

Provided Methods

Returns this buffer as a str.

This is an utility method, as it simply relies on the AsRef<str> implementation.

Reads the given character range.

Clears all characters in this buffer

Replaces all contents of this string with text

Clears all characters in this buffer and returns a string of the contents.

Implementations on Foreign Types

Immutable view of a &str!

Implementors