pub enum MatchError {
MissingTrailingSlash,
ExtraTrailingSlash,
NotFound,
}
Expand description
A failed match attempt.
use matchit::{MatchError, Router};
let mut router = Router::new();
router.insert("/home", "Welcome!")?;
router.insert("/blog/", "Our blog.")?;
// a route exists without the trailing slash
if let Err(err) = router.at("/home/") {
assert_eq!(err, MatchError::ExtraTrailingSlash);
}
// a route exists with a trailing slash
if let Err(err) = router.at("/blog") {
assert_eq!(err, MatchError::MissingTrailingSlash);
}
// no routes match
if let Err(err) = router.at("/foobar") {
assert_eq!(err, MatchError::NotFound);
}
Variants§
MissingTrailingSlash
The path was missing a trailing slash.
ExtraTrailingSlash
The path had an extra trailing slash.
NotFound
No matching route was found.
Trait Implementations§
Source§impl Clone for MatchError
impl Clone for MatchError
Source§fn clone(&self) -> MatchError
fn clone(&self) -> MatchError
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for MatchError
impl Debug for MatchError
Source§impl Display for MatchError
impl Display for MatchError
Source§impl Error for MatchError
impl Error for MatchError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()
Source§impl PartialEq for MatchError
impl PartialEq for MatchError
impl Copy for MatchError
impl Eq for MatchError
impl StructuralPartialEq for MatchError
Auto Trait Implementations§
impl Freeze for MatchError
impl RefUnwindSafe for MatchError
impl Send for MatchError
impl Sync for MatchError
impl Unpin for MatchError
impl UnwindSafe for MatchError
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 1 byte
Size for each variant:
MissingTrailingSlash
: 0 bytesExtraTrailingSlash
: 0 bytesNotFound
: 0 bytes