pub struct TextBuffer { /* private fields */ }Expand description
A mutable text buffer backed by a String.
Implementations§
Source§impl TextBuffer
impl TextBuffer
pub fn new() -> Self
pub fn with_capacity(cap: usize) -> Self
Sourcepub fn append_line(&mut self, s: &str)
pub fn append_line(&mut self, s: &str)
Append a line (adds newline at end).
Sourcepub fn char_count(&self) -> usize
pub fn char_count(&self) -> usize
Total character count.
pub fn is_empty(&self) -> bool
Sourcepub fn line_count(&self) -> usize
pub fn line_count(&self) -> usize
Returns the number of lines.
Sourcepub fn find(&self, needle: &str) -> Option<usize>
pub fn find(&self, needle: &str) -> Option<usize>
Search for a substring; returns the byte offset of the first match.
Sourcepub fn count_occurrences(&self, needle: &str) -> usize
pub fn count_occurrences(&self, needle: &str) -> usize
Count occurrences of a substring.
Sourcepub fn replace_all(&mut self, from: &str, to: &str)
pub fn replace_all(&mut self, from: &str, to: &str)
Replace all occurrences of from with to.
Sourcepub fn truncate(&mut self, n: usize)
pub fn truncate(&mut self, n: usize)
Truncate to the first n bytes (must be on a char boundary).
pub fn append_count(&self) -> u64
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TextBuffer
impl RefUnwindSafe for TextBuffer
impl Send for TextBuffer
impl Sync for TextBuffer
impl Unpin for TextBuffer
impl UnsafeUnpin for TextBuffer
impl UnwindSafe for TextBuffer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more