pub struct BuildError { /* private fields */ }
regex-automata
and regex-lita
only.Expand description
An error that occurred during the construction of a DFA.
This error does not provide many introspection capabilities. There are generally only two things you can do with it:
- Obtain a human readable message via its
std::fmt::Display
impl. - Access an underlying
nfa::thompson::BuildError
type from itssource
method via thestd::error::Error
trait. This error only occurs when using convenience routines for building a DFA directly from a pattern string.
When the std
feature is enabled, this implements the std::error::Error
trait.
Implementations§
Source§impl BuildError
impl BuildError
Sourcepub fn is_size_limit_exceeded(&self) -> bool
pub fn is_size_limit_exceeded(&self) -> bool
Returns true if and only if this error corresponds to an error with DFA construction that occurred because of exceeding a size limit.
While this can occur when size limits like Config::dfa_size_limit
or Config::determinize_size_limit
are exceeded, this can also occur
when the number of states or patterns exceeds a hard-coded maximum.
(Where these maximums are derived based on the values representable by
StateID
and PatternID
.)
This predicate is useful in contexts where you want to distinguish between errors related to something provided by an end user (for example, an invalid regex pattern) and errors related to configured heuristics. For example, building a DFA might be an optimization that you want to skip if construction fails because of an exceeded size limit, but where you want to bubble up an error if it fails for some other reason.
§Example
use regex_automata::{dfa::{dense, Automaton}, Input};
let err = dense::Builder::new()
.configure(dense::Config::new()
.determinize_size_limit(Some(100_000))
)
.build(r"\w{20}")
.unwrap_err();
// This error occurs because a size limit was exceeded.
// But things are otherwise valid.
assert!(err.is_size_limit_exceeded());
let err = dense::Builder::new()
.build(r"\bxyz\b")
.unwrap_err();
// This error occurs because a Unicode word boundary
// was used without enabling heuristic support for it.
// So... not related to size limits.
assert!(!err.is_size_limit_exceeded());
let err = dense::Builder::new()
.build(r"(xyz")
.unwrap_err();
// This error occurs because the pattern is invalid.
// So... not related to size limits.
assert!(!err.is_size_limit_exceeded());
Trait Implementations§
Source§impl Clone for BuildError
impl Clone for BuildError
Source§fn clone(&self) -> BuildError
fn clone(&self) -> BuildError
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for BuildError
impl Debug for BuildError
Source§impl Display for BuildError
impl Display for BuildError
Source§impl Error for BuildError
impl Error for BuildError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
Auto Trait Implementations§
impl Freeze for BuildError
impl RefUnwindSafe for BuildError
impl Send for BuildError
impl Sync for BuildError
impl Unpin for BuildError
impl UnwindSafe for BuildError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more