Skip to main content

BufferEdit

Trait BufferEdit 

Source
pub trait BufferEdit: Send {
    // Required methods
    fn insert_at(&mut self, pos: Pos, text: &str);
    fn delete_range(&mut self, range: Range<Pos>);
    fn replace_range(&mut self, range: Range<Pos>, replacement: &str);

    // Provided method
    fn replace_all(&mut self, text: &str) { ... }
}
Expand description

Mutating sub-trait of View. Distinct trait name from the crate-root Edit struct — this one carries methods, the other is a value type.

Required Methods§

Source

fn insert_at(&mut self, pos: Pos, text: &str)

Insert text at pos. Implementations clamp out-of-range positions to the document end.

Source

fn delete_range(&mut self, range: Range<Pos>)

Delete the half-open range.

Source

fn replace_range(&mut self, range: Range<Pos>, replacement: &str)

Replace the half-open range with replacement.

Provided Methods§

Source

fn replace_all(&mut self, text: &str)

Replace the entire buffer content with text. The cursor is clamped to the surviving content. Used by :e! / undo restore / snapshot replay where expressing “replace whole buffer” via [replace_range] would require knowing the end position. Default impl uses [replace_range] with a best-effort end (u32::MAX / u32::MAX); the canonical in-tree impl overrides it for a single-shot rebuild.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl BufferEdit for View

Source§

fn insert_at(&mut self, pos: Pos, text: &str)

Source§

fn delete_range(&mut self, range: Range<Pos>)

Source§

fn replace_range(&mut self, range: Range<Pos>, replacement: &str)

Source§

fn replace_all(&mut self, text: &str)

Implementors§