pub struct Selections { /* private fields */ }Expand description
A non-empty, document-ordered, non-overlapping set of selections.
Every mutating method ends by restoring those invariants, so no editing code has to defend against an out-of-order or overlapping set.
Implementations§
Source§impl Selections
impl Selections
pub fn single(selection: Selection) -> Self
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Always at least 1 — the type’s invariant.
No is_empty to pair with it: it could only ever return false, and a
method that is a constant invites callers to branch on something that
never varies. The invariant is the API.
pub fn primary(&self) -> Selection
pub fn iter(&self) -> impl Iterator<Item = &Selection>
Sourcepub fn set_single(&mut self, selection: Selection)
pub fn set_single(&mut self, selection: Selection)
Replace everything with one selection.
Sourcepub fn map_in_place(&mut self, f: impl FnMut(Selection) -> Selection)
pub fn map_in_place(&mut self, f: impl FnMut(Selection) -> Selection)
Rewrite every selection, then restore the invariants.
Sourcepub fn collapse_to_heads(&mut self)
pub fn collapse_to_heads(&mut self)
Drop every selection but the primary, and reduce it to its head.
Trait Implementations§
Source§impl Clone for Selections
impl Clone for Selections
Source§fn clone(&self) -> Selections
fn clone(&self) -> Selections
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for Selections
impl Debug for Selections
Auto Trait Implementations§
impl Freeze for Selections
impl RefUnwindSafe for Selections
impl Send for Selections
impl Sync for Selections
impl Unpin for Selections
impl UnsafeUnpin for Selections
impl UnwindSafe for Selections
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