[][src]Struct vimwiki::elements::Region

pub struct Region { /* fields omitted */ }

Represents a region in a string or file, comprised of a start and end

Implementations

impl Region[src]

pub fn new(offset: usize, len: usize) -> Self[src]

Constructs a new region with the given offset and length, containing no extra information

pub fn new_with_position(offset: usize, len: usize, position: Position) -> Self[src]

Constructs a new region with the given offset, length, and extra information about the line & column position

pub fn with_position(self, position: Position) -> Self[src]

Consumes the given region and returns a new one with its position set to the provided position

pub fn from_span_with_position(span: Span<'_>) -> Self[src]

Constructs a new region based on the offset and length of the given span. Additionally, computes the line & column position of the region.

pub fn contains(&self, offset: usize) -> bool[src]

Checks if a position is contained within this region

pub fn offset(&self) -> usize[src]

The offset of the region relative to some span of input

pub fn len(&self) -> usize[src]

The length of the region

pub fn is_empty(&self) -> bool[src]

Returns true if the length of the region is zero

pub fn position(&self) -> Option<Position>[src]

Returns the position of the region relative to some span of input

Can be none if the region was not constructed with a position

Trait Implementations

impl Clone for Region[src]

impl Copy for Region[src]

impl Debug for Region[src]

impl Default for Region[src]

impl<'de> Deserialize<'de> for Region[src]

impl Eq for Region[src]

impl From<(usize, usize)> for Region[src]

impl From<Range<usize>> for Region[src]

fn from(range: Range<usize>) -> Self[src]

Converts from start..end to Region { offset: start, len: end - start } where end < start will result in a length of zero

impl From<RangeInclusive<usize>> for Region[src]

fn from(range: RangeInclusive<usize>) -> Self[src]

Converts from start..=end to Region { offset: start, len: end - start + 1 } where end + 1 < start will result in a length of zero

impl From<RangeTo<usize>> for Region[src]

fn from(range: RangeTo<usize>) -> Self[src]

Converts from ..end to Region { offset: 0, len: end }

impl From<RangeToInclusive<usize>> for Region[src]

fn from(range: RangeToInclusive<usize>) -> Self[src]

Converts from ..=end to Region { offset: 0, len: end + 1 }

impl Hash for Region[src]

impl PartialEq<Region> for Region[src]

impl Serialize for Region[src]

impl StructuralEq for Region[src]

impl StructuralPartialEq for Region[src]

Auto Trait Implementations

impl RefUnwindSafe for Region

impl Send for Region

impl Sync for Region

impl Unpin for Region

impl UnwindSafe for Region

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.