pub trait TextBuffer {
// Required methods
fn is_mutable(&self) -> bool;
fn as_str(&self) -> &str;
fn insert_text(&mut self, text: &str, char_index: usize) -> usize;
fn delete_char_range(&mut self, char_range: Range<usize>);
// Provided methods
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§
Sourcefn is_mutable(&self) -> bool
fn is_mutable(&self) -> bool
Can this text be edited?
Sourcefn insert_text(&mut self, text: &str, char_index: usize) -> usize
fn insert_text(&mut self, text: &str, char_index: usize) -> usize
Sourcefn delete_char_range(&mut self, char_range: Range<usize>)
fn delete_char_range(&mut self, char_range: Range<usize>)
Deletes a range of text char_range from this buffer.
§Notes
char_range is a character range, not a byte range.
Provided Methods§
Sourcefn char_range(&self, char_range: Range<usize>) -> &str
fn char_range(&self, char_range: Range<usize>) -> &str
Reads the given character range.
fn byte_index_from_char_index(&self, char_index: usize) -> usize
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementations on Foreign Types§
Source§impl TextBuffer for String
impl TextBuffer for String
fn is_mutable(&self) -> bool
fn as_str(&self) -> &str
fn insert_text(&mut self, text: &str, char_index: usize) -> usize
fn delete_char_range(&mut self, char_range: Range<usize>)
fn clear(&mut self)
fn replace(&mut self, text: &str)
fn take(&mut self) -> String
Source§impl<'a> TextBuffer for &'a str
Immutable view of a &str!
impl<'a> TextBuffer for &'a str
Immutable view of a &str!