pub struct Selection {
pub anchor: usize,
pub head: usize,
}Expand description
An anchored selection: anchor is where it started, head is the moving end.
Fields§
§anchor: usize§head: usizeImplementations§
Source§impl Selection
impl Selection
Sourcepub fn new(anchor: usize, head: usize) -> Selection
pub fn new(anchor: usize, head: usize) -> Selection
A selection spanning [anchor, head] (order-independent for range queries).
pub fn is_empty(&self) -> bool
Sourcepub fn is_forward(&self) -> bool
pub fn is_forward(&self) -> bool
Whether the selection is anchored before the head (forward) vs after (backward).
Sourcepub fn extend_to(&mut self, head: usize)
pub fn extend_to(&mut self, head: usize)
Moves the head, keeping the anchor (extends the selection).
Sourcepub fn collapse_to(&mut self, pos: usize)
pub fn collapse_to(&mut self, pos: usize)
Collapses the selection to a point at pos.
Trait Implementations§
impl Copy for Selection
impl Eq for Selection
impl StructuralPartialEq for Selection
Auto Trait Implementations§
impl Forget for Selection
impl Freeze for Selection
impl RefUnwindSafe for Selection
impl Send for Selection
impl Sync for Selection
impl Unpin for Selection
impl UnsafeUnpin for Selection
impl UnwindSafe for Selection
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