Struct PatternID

struct PatternID(_)

The identifier of a regex pattern, represented by a SmallIndex.

The identifier for a pattern corresponds to its relative position among other patterns in a single finite state machine. Namely, when building a multi-pattern regex engine, one must supply a sequence of patterns to match. The position (starting at 0) of each pattern in that sequence represents its identifier. This identifier is in turn used to identify and report matches of that pattern in various APIs.

See the SmallIndex type for more information about what it means for a pattern ID to be a "small index."

Note that this type is defined in the util::primitives module, but it is also re-exported at the crate root due to how common it is.

Implementations

impl PatternID

fn new(value: usize) -> Result<PatternID, PatternIDError>

Create a new value that is represented by a "small index."

If the given index exceeds the maximum allowed value, then this returns an error.

const fn new_unchecked(value: usize) -> PatternID

Create a new value without checking whether the given argument exceeds the maximum.

Using this routine with an invalid value will result in unspecified behavior, but not undefined behavior. In particular, an invalid ID value is likely to cause panics or possibly even silent logical errors.

Callers must never rely on this type to be within a certain range for memory safety.

fn must(value: usize) -> PatternID

Like new, but panics if the given value is not valid.

const fn as_usize(self: &Self) -> usize

Return the internal value as a usize. This is guaranteed to never overflow usize.

const fn as_u64(self: &Self) -> u64

Return the internal value as a u64. This is guaranteed to never overflow.

const fn as_u32(self: &Self) -> u32

Return the internal value as a u32. This is guaranteed to never overflow u32.

const fn as_i32(self: &Self) -> i32

Return the internal value as a i32. This is guaranteed to never overflow an i32`.

fn one_more(self: &Self) -> usize

Returns one more than this value as a usize.

Since values represented by a "small index" have constraints on their maximum value, adding 1 to it will always fit in a usize, u32 and a i32.

fn from_ne_bytes(bytes: [u8; 4]) -> Result<PatternID, PatternIDError>

Decode this value from the bytes given using the native endian byte order for the current target.

If the decoded integer is not representable as a small index for the current target, then this returns an error.

fn from_ne_bytes_unchecked(bytes: [u8; 4]) -> PatternID

Decode this value from the bytes given using the native endian byte order for the current target.

This is analogous to new_unchecked in that is does not check whether the decoded integer is representable as a small index.

fn to_ne_bytes(self: &Self) -> [u8; 4]

Return the underlying integer as raw bytes in native endian format.

impl Clone for PatternID

fn clone(self: &Self) -> PatternID

impl Copy for PatternID

impl Debug for PatternID

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

impl Default for PatternID

fn default() -> PatternID

impl Eq for PatternID

impl Freeze for PatternID

impl From for PatternID

fn from(value: u8) -> PatternID

impl Hash for PatternID

fn hash<__H: $crate::hash::Hasher>(self: &Self, state: &mut __H)

impl Ord for PatternID

fn cmp(self: &Self, other: &PatternID) -> Ordering

impl PartialEq for PatternID

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

impl PartialOrd for PatternID

fn partial_cmp(self: &Self, other: &PatternID) -> Option<Ordering>

impl RefUnwindSafe for PatternID

impl Send for PatternID

impl StructuralPartialEq for PatternID

impl Sync for PatternID

impl TryFrom for PatternID

fn try_from(value: u16) -> Result<PatternID, PatternIDError>

impl TryFrom for PatternID

fn try_from(value: u32) -> Result<PatternID, PatternIDError>

impl TryFrom for PatternID

fn try_from(value: u64) -> Result<PatternID, PatternIDError>

impl TryFrom for PatternID

fn try_from(value: usize) -> Result<PatternID, PatternIDError>

impl Unpin for PatternID

impl UnsafeUnpin for PatternID

impl UnwindSafe for PatternID

impl<T> Any for PatternID

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for PatternID

fn borrow(self: &Self) -> &T

impl<T> BorrowMut for PatternID

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

impl<T> CloneToUninit for PatternID

unsafe fn clone_to_uninit(self: &Self, dest: *mut u8)

impl<T> From for PatternID

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> ToOwned for PatternID

fn to_owned(self: &Self) -> T
fn clone_into(self: &Self, target: &mut T)

impl<T, U> Into for PatternID

fn into(self: Self) -> U

Calls U::from(self).

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

impl<T, U> TryFrom for PatternID

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

impl<T, U> TryInto for PatternID

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