#[repr(transparent)]
pub struct PatternID(_);
Expand description

The identifier of a pattern in an Aho-Corasick automaton.

It is represented by a u32 even on 64-bit systems in order to conserve space. Namely, on all targets, this type guarantees that its value will fit in a u32, i32, usize and an isize. This means that on 16-bit targets, for example, this type’s maximum value will never overflow an isize, which means it will never overflow a i16 even though its internal representation is still a u32.

Safety

While a PatternID is meant to guarantee that its value fits into usize without using as much space as a usize on all targets, callers must not rely on this property for safety. Callers may choose to rely on this property for correctness however. For example, creating a StateID with an invalid value can be done in entirely safe code. This may in turn result in panics or silent logical errors.

Implementations

The maximum value.

The total number of values that can be represented.

The zero value.

The number of bytes that a single value uses in memory.

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.

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.

Create a new value from a u32 without checking whether the given value 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.

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

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

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

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

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

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.

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.

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.

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

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more
Converts to this type from the input type.
Feeds this value into the given Hasher. Read more
Feeds a slice of this type into the given Hasher. Read more
The returned type after indexing.
Performs the indexing (container[index]) operation. Read more
The returned type after indexing.
Performs the indexing (container[index]) operation. Read more
Performs the mutable indexing (container[index]) operation. Read more
Performs the mutable indexing (container[index]) operation. Read more
This method returns an Ordering between self and other. Read more
Compares and returns the maximum of two values. Read more
Compares and returns the minimum of two values. Read more
Restrict a value to a certain interval. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
This method returns an ordering between self and other values if one exists. Read more
This method tests less than (for self and other) and is used by the < operator. Read more
This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
This method tests greater than (for self and other) and is used by the > operator. Read more
This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.