pub enum TextSelectionOperator {
    Equals {
        all: bool,
        negate: bool,
    },
    Overlaps {
        all: bool,
        negate: bool,
    },
    Embeds {
        all: bool,
        negate: bool,
    },
    Embedded {
        all: bool,
        negate: bool,
        limit: Option<usize>,
    },
    Before {
        all: bool,
        negate: bool,
        limit: Option<usize>,
    },
    After {
        all: bool,
        negate: bool,
        limit: Option<usize>,
    },
    Precedes {
        all: bool,
        negate: bool,
    },
    Succeeds {
        all: bool,
        negate: bool,
    },
    SameBegin {
        all: bool,
        negate: bool,
    },
    SameEnd {
        all: bool,
        negate: bool,
    },
    InSet {
        all: bool,
        negate: bool,
    },
    SameRange {
        all: bool,
        negate: bool,
    },
}
Expand description

The TextSelectionOperator, simply put, allows comparison of two TextSelection instances. It allows testing for all kinds of spatial relations (as embodied by this enum) in which two TextSelection instances can be, such as overlap, embedding, adjacency, etc…

Rather than operator on single TextSelection instances, the implementation goes a bit further and can act also on the basis of TextSelectionSet rather than TextSelection, allowing you to compare two sets, each containing possibly multiple TextSelections, at once.

Use the various methods on this type to quickly instantiate a variant.

Variants§

§

Equals

Fields

§all: bool
§negate: bool

Both sets cover the exact same TextSelections, and all are covered (cf. textfabric’s ==), commutative, transitive

§

Overlaps

Fields

§all: bool
§negate: bool

All items in both sets must cover the exact same TextSelection. This would be fairly useless, it just means both sets contain only one TextSelection and it’s the same one Each TextSelection in A overlaps with a TextSelection in B (cf. textfabric’s &&), commutative If modifier all is set: Each TextSelection in A overlaps with all TextSelection in B (cf. textfabric’s &&), commutative

§

Embeds

Fields

§all: bool
§negate: bool

All TextSelections in B are embedded by a TextSelection in A (cf. textfabric’s [[) If modifier all is set: All TextSelections in B are embedded by all TextSelection in A (cf. textfabric’s [[)

§

Embedded

Fields

§all: bool
§negate: bool
§limit: Option<usize>

All TextSelections in A are embedded by a TextSelection in B (cf. textfabric’s ]]) If modifier all is set: All TextSelections in A are embedded by all TextSelection in B (cf. textfabric’s ]]) The limit, if set, constrains the lookup range (in unicode points), which can positively affect performance

§

Before

Fields

§all: bool
§negate: bool
§limit: Option<usize>

Each TextSelections in A comes before a textselection in B If modifier all is set: All TextSelections in A precede (come before) all textselections in B. There is no overlap (cf. textfabric’s <<) The limit, if set, constrains the lookup range (in unicode points), which can positively affect performance

§

After

Fields

§all: bool
§negate: bool
§limit: Option<usize>

Each TextSeleciton In A succeeds (comes after) a textselection in B If modifier all is set: All TextSelections in A succeed (come after) all textselections in B. There is no overlap (cf. textfabric’s >>) The limit, if set, constrains the lookup range (in unicode points), which can positively affect performance

§

Precedes

Fields

§all: bool
§negate: bool

Each TextSelection in A ends where at least one TextSelection in B begins. If modifier all is set: The rightmost TextSelections in A end where the leftmost TextSelection in B begins (cf. textfabric’s <:)

§

Succeeds

Fields

§all: bool
§negate: bool

Each TextSelection in A begis where at least one TextSelection in A ends. If modifier all is set: The leftmost TextSelection in A starts where the rightmost TextSelection in B ends (cf. textfabric’s :>)

§

SameBegin

Fields

§all: bool
§negate: bool

Each TextSelection in A starts where a TextSelection in B starts If modifier all is set: The leftmost TextSelection in A starts where the leftmost TextSelection in B start (cf. textfabric’s =:)

§

SameEnd

Fields

§all: bool
§negate: bool

Each TextSelection in A ends where a TextSelection in B ends If modifier all is set: The rightmost TextSelection in A ends where the rights TextSelection in B ends (cf. textfabric’s :=)

§

InSet

Fields

§all: bool
§negate: bool

Each TextSelection in A is in B as well, this is similar to Equals but allows for set B having unmatched items

§

SameRange

Fields

§all: bool
§negate: bool

The leftmost TextSelection in A starts where the leftmost TextSelection in A starts and the rightmost TextSelection in A ends where the rights TextSelection in B ends (cf. textfabric’s ::)

Implementations§

source§

impl TextSelectionOperator

source

pub fn all(&self) -> bool

source

pub fn as_str(&self) -> &'static str

source

pub fn equals() -> Self

source

pub fn overlaps() -> Self

source

pub fn embeds() -> Self

source

pub fn embedded() -> Self

source

pub fn before() -> Self

source

pub fn after() -> Self

source

pub fn precedes() -> Self

source

pub fn succeeds() -> Self

source

pub fn samebegin() -> Self

source

pub fn sameend() -> Self

source

pub fn samerange() -> Self

source

pub fn inset() -> Self

source

pub fn with_limit(self, limit: usize) -> Self

Constrains the operator to a limit range (in unicode points)

source

pub fn toggle_negate(&self) -> Self

source

pub fn toggle_all(&self) -> Self

Trait Implementations§

source§

impl Clone for TextSelectionOperator

source§

fn clone(&self) -> TextSelectionOperator

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for TextSelectionOperator

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl PartialEq for TextSelectionOperator

source§

fn eq(&self, other: &TextSelectionOperator) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Copy for TextSelectionOperator

source§

impl StructuralPartialEq for TextSelectionOperator

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V