Struct spinoso_regexp::Options

source ·
pub struct Options { /* private fields */ }
Expand description

Configuration options for Ruby Regexps.

Options can be supplied either as an Integer object to Regexp::new or inline in Regexp literals like /artichoke/i.

Implementations§

source§

impl Options

source

pub const fn new() -> Self

Constructs a new, default Options.

source

pub const fn with_ignore_case() -> Self

An options instance that has only case insensitive mode enabled.

source

pub fn try_from_int(options: i64) -> Option<Self>

Try to parse an Options from a full-width i64.

If options cannot be converted losslessly to a u8, this function returns None. See From<u8>.

For a conversion from i64 that truncates the given options to u8, see From<i64>.

source

pub fn flags(self) -> Flags

Convert an Options to its bit flag representation.

Alias for the corresponding Into<Flags> implementation.

source

pub const fn into_bits(self) -> u8

Convert an Options to its bit representation.

Alias for the corresponding Into<u8> implementation.

source

pub const fn multiline(self) -> RegexpOption

Whether these Options are configured for multiline mode.

source

pub const fn ignore_case(self) -> RegexpOption

Whether these Options are configured for case-insensitive mode.

source

pub const fn extended(self) -> RegexpOption

Whether these Options are configured for extended mode with insignificant whitespace.

source

pub const fn is_literal(self) -> bool

Whether the Regexp was parsed as a literal, e.g. '/artichoke/i.

This enables Ruby parsers to inject whether a Regexp is a literal to the core library. Literal Regexps have some special behavior regarding capturing groups and report parse failures differently.

source

pub const fn as_display_modifier(self) -> &'static str

Serialize the option flags to a string suitable for a Regexp display or debug implementation.

See also Regexp#inspect.

source

pub const fn as_inline_modifier(self) -> &'static str

Serialize the option flags to a string suitable for including in a raw pattern for configuring an underlying Regexp.

source

pub fn set(&mut self, other: Flags, value: bool)

Inserts or removes the specified flags depending on the passed value.

Trait Implementations§

source§

impl Clone for Options

source§

fn clone(&self) -> Options

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 Options

source§

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

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

impl Default for Options

source§

fn default() -> Options

Returns the “default value” for a type. Read more
source§

impl Display for Options

source§

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

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

impl From<&[u8]> for Options

source§

fn from(options: &[u8]) -> Self

Converts to this type from the input type.
source§

impl From<&str> for Options

source§

fn from(options: &str) -> Self

Converts to this type from the input type.
source§

impl From<Flags> for Options

source§

fn from(flags: Flags) -> Self

Converts to this type from the input type.
source§

impl From<Option<bool>> for Options

source§

fn from(options: Option<bool>) -> Self

Converts to this type from the input type.
source§

impl From<Options> for Flags

source§

fn from(opts: Options) -> Self

Convert an Options to its bit flag representation.

source§

impl From<Options> for RegexOptions

source§

fn from(opts: Options) -> Self

Converts to this type from the input type.
source§

impl From<Options> for i64

source§

fn from(opts: Options) -> Self

Convert an Options to its widened bit representation.

source§

impl From<Options> for u8

source§

fn from(opts: Options) -> Self

Convert an Options to its bit representation.

source§

impl From<String> for Options

source§

fn from(options: String) -> Self

Converts to this type from the input type.
source§

impl From<Vec<u8>> for Options

source§

fn from(options: Vec<u8>) -> Self

Converts to this type from the input type.
source§

impl From<i64> for Options

source§

fn from(flags: i64) -> Self

Truncate the given i64 to one byte and generate flags.

See From<u8>. For a conversion that fails if the given i64 is larger than u8::MAX, see try_from_int.

source§

impl From<u8> for Options

source§

fn from(flags: u8) -> Self

Converts to this type from the input type.
source§

impl Hash for Options

source§

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

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl Ord for Options

source§

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

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
source§

impl PartialEq for Options

source§

fn eq(&self, other: &Options) -> 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 PartialOrd for Options

source§

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

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

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

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

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

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

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

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Copy for Options

source§

impl Eq for Options

source§

impl StructuralPartialEq for Options

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.

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> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. 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.