pub struct Content { /* private fields */ }Expand description
Per-document state shared across all crate::Buffer views of the
same file. Wrap in Arc<Mutex<Content>> and pass to
crate::Buffer::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
Content 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 Content
impl RefUnwindSafe for Content
impl Send for Content
impl Sync for Content
impl Unpin for Content
impl UnsafeUnpin for Content
impl UnwindSafe for Content
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