pub struct Buffer { /* private fields */ }Expand description
Per-document state shared across all crate::View views of the
same file. Wrap in Arc<Mutex<Buffer>> and pass to
crate::View::new_view to create an additional window onto the
same content.
Uses a ropey::Rope for O(log N) edits and O(1) byte-length queries.
The rope always contains at least one logical line: a freshly constructed
Buffer holds an empty rope (which ropey reports as 1 line) so
cursor positions never need an “is the buffer empty?” branch.
§Line semantics
ropey::Rope::len_lines() and split('\n').count() agree for all inputs:
""→ 1 line"foo\n"→ 2 lines (trailing empty line)"a\nb\n"→ 3 lines
Rope::line(i) returns a RopeSlice that includes the trailing \n
for non-final lines. Public accessors strip it before returning String.
Implementations§
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Buffer
impl RefUnwindSafe for Buffer
impl Send for Buffer
impl Sync for Buffer
impl Unpin for Buffer
impl UnsafeUnpin for Buffer
impl UnwindSafe for Buffer
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