pub enum CursorAffinity {
Forward,
Backward,
}Expand description
Decides how the cursor should be placed around special areas of text.
Ex:
let j = // soft linewrap
1 + 2 + 3;where let j = has the issue that there’s two positions you might want your cursor to be:
let j = | or |1 + 2 + 3;
These are the same offset in the text, but it feels more natural to have it move in a certain
way.
If you’re at let j =| and you press the right-arrow key, then it uses your backwards
affinity to keep you on the line at let j = |.
If you’re at 1| + 2 + 3; and you press the left-arrow key, then it uses your forwards affinity
to keep you on the line at |1 + 2 + 3;.
For other special text, like inlay hints, this can also apply.
let j<: String> = ...where <: String> is our inlay hint, then
let |j<: String> = and you press the right-arrow key, then it uses your backwards affinity to
keep you on the same side of the hint, let j|<: String>.
let j<: String> |= and you press the right-arrow key, then it uses your forwards affinity to
keep you on the same side of the hint, let j<: String>| =.
Variants§
Implementations§
Source§impl CursorAffinity
impl CursorAffinity
pub fn invert(&self) -> CursorAffinity
Trait Implementations§
Source§impl Clone for CursorAffinity
impl Clone for CursorAffinity
Source§fn clone(&self) -> CursorAffinity
fn clone(&self) -> CursorAffinity
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for CursorAffinity
impl Debug for CursorAffinity
Source§impl<'de> Deserialize<'de> for CursorAffinity
impl<'de> Deserialize<'de> for CursorAffinity
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<CursorAffinity, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<CursorAffinity, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for CursorAffinity
impl PartialEq for CursorAffinity
Source§impl Serialize for CursorAffinity
impl Serialize for CursorAffinity
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl Copy for CursorAffinity
impl Eq for CursorAffinity
impl StructuralPartialEq for CursorAffinity
Auto Trait Implementations§
impl Freeze for CursorAffinity
impl RefUnwindSafe for CursorAffinity
impl Send for CursorAffinity
impl Sync for CursorAffinity
impl Unpin for CursorAffinity
impl UnsafeUnpin for CursorAffinity
impl UnwindSafe for CursorAffinity
Blanket Implementations§
§impl<T> AnyEq for T
impl<T> AnyEq for T
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
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>
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