pub enum Bias {
Left,
Right,
}
Expand description
Bias is used to settle ambiguities when determining positions in an ordered sequence.
The primary use case is for text, where Bias influences which character an offset or anchor is associated with.
§Examples
Given the buffer AˇBCD
:
- The offset of the cursor is 1
- Bias::Left would attach the cursor to the character
A
- Bias::Right would attach the cursor to the character
B
Given the buffer A«BCˇ»D
:
- The offset of the cursor is 3, and the selection is from 1 to 3
- The left anchor of the selection has Bias::Right, attaching it to the character
B
- The right anchor of the selection has Bias::Left, attaching it to the character
C
Given the buffer {ˇ<...>
, where <...>
is a folded region:
- The display offset of the cursor is 1, but the offset in the buffer is determined by the bias
- Bias::Left would attach the cursor to the character
{
, with a buffer offset of 1 - Bias::Right would attach the cursor to the first character of the folded region, and the buffer offset would be the offset of the first character of the folded region
Variants§
Implementations§
Trait Implementations§
Source§impl Ord for Bias
impl Ord for Bias
Source§impl PartialOrd for Bias
impl PartialOrd for Bias
impl Copy for Bias
impl Eq for Bias
impl StructuralPartialEq for Bias
Auto Trait Implementations§
impl Freeze for Bias
impl RefUnwindSafe for Bias
impl Send for Bias
impl Sync for Bias
impl Unpin for Bias
impl UnwindSafe for Bias
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more