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
impl Options
Sourcepub const fn with_ignore_case() -> Self
pub const fn with_ignore_case() -> Self
An options instance that has only case insensitive mode enabled.
Sourcepub fn try_from_int(options: i64) -> Option<Self>
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>
.
Sourcepub fn flags(self) -> Flags
pub fn flags(self) -> Flags
Convert an Options
to its bit flag representation.
Alias for the corresponding Into<Flags>
implementation.
Sourcepub const fn into_bits(self) -> u8
pub const fn into_bits(self) -> u8
Convert an Options
to its bit representation.
Alias for the corresponding Into<u8>
implementation.
Sourcepub const fn multiline(self) -> RegexpOption
pub const fn multiline(self) -> RegexpOption
Whether these Options
are configured for multiline mode.
Sourcepub const fn ignore_case(self) -> RegexpOption
pub const fn ignore_case(self) -> RegexpOption
Whether these Options
are configured for case-insensitive mode.
Sourcepub const fn extended(self) -> RegexpOption
pub const fn extended(self) -> RegexpOption
Whether these Options
are configured for extended mode with
insignificant whitespace.
Sourcepub const fn is_literal(self) -> bool
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.
Sourcepub const fn as_display_modifier(self) -> &'static str
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
.
Sourcepub const fn as_inline_modifier(self) -> &'static str
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
.