pub struct SelRegion {
pub start: usize,
pub end: usize,
pub horiz: Option<ColPosition>,
}
Fields§
§start: usize
Region start offset
end: usize
Region end offset
horiz: Option<ColPosition>
Horizontal rules for multiple selection
Implementations§
Source§impl SelRegion
impl SelRegion
Sourcepub fn new(start: usize, end: usize, horiz: Option<ColPosition>) -> SelRegion
pub fn new(start: usize, end: usize, horiz: Option<ColPosition>) -> SelRegion
Creates new SelRegion
from start
and end
offset.
Sourcepub fn caret(offset: usize) -> SelRegion
pub fn caret(offset: usize) -> SelRegion
Creates a caret SelRegion
,
i.e. start
and end
position are both set to offset
value.
Sourcepub fn min(self) -> usize
pub fn min(self) -> usize
Return the minimum value between region’s start and end position
Example:
let region = SelRegion::new(1, 10, None);
assert_eq!(region.min(), region.start);
let region = SelRegion::new(42, 1, None);
assert_eq!(region.min(), region.end);
Sourcepub fn max(self) -> usize
pub fn max(self) -> usize
Return the maximum value between region’s start and end position.
Example:
let region = SelRegion::new(1, 10, None);
assert_eq!(region.max(), region.end);
let region = SelRegion::new(42, 1, None);
assert_eq!(region.max(), region.start);
Sourcepub fn is_caret(self) -> bool
pub fn is_caret(self) -> bool
A SelRegion
is considered to be a caret when its start and end position are equal.
Example:
let region = SelRegion::new(1, 1, None);
assert!(region.is_caret());
Sourcepub fn merge_with(self, other: SelRegion) -> SelRegion
pub fn merge_with(self, other: SelRegion) -> SelRegion
Merge two SelRegion
into a single one.
Example:
let region = SelRegion::new(1, 2, None);
let other = SelRegion::new(3, 4, None);
assert_eq!(region.merge_with(other), SelRegion::new(1, 4, None));
Trait Implementations§
Source§impl<'de> Deserialize<'de> for SelRegion
impl<'de> Deserialize<'de> for SelRegion
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Copy for SelRegion
impl StructuralPartialEq for SelRegion
Auto Trait Implementations§
impl Freeze for SelRegion
impl RefUnwindSafe for SelRegion
impl Send for SelRegion
impl Sync for SelRegion
impl Unpin for SelRegion
impl UnwindSafe for SelRegion
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