rocket::catcher

Struct Catcher

Source
pub struct Catcher {
    pub name: Option<Cow<'static, str>>,
    pub code: Option<u16>,
    pub handler: Box<dyn Handler>,
    /* private fields */
}
Expand description

An error catching route.

Catchers are routes that run when errors are produced by the application. They consist of a Handler and an optional status code to match against arising errors. Errors arise from the the following sources:

  • A failing guard.
  • A failing responder.
  • A forwarding guard.
  • Routing failure.

Each error or forward is paired with a status code. Guards and responders indicate the status code themselves via their Err and Outcome return value. A complete routing failure is always a 404. Rocket invokes the error handler for the catcher with an error’s status code, or in the case of every route resulting in a forward, the last forwarded status code.

§Error Handler Restrictions

Because error handlers are a last resort, they should not fail to produce a response. If an error handler does fail, Rocket invokes its default 500 error catcher. Error handlers cannot forward.

§Routing

If a route fails by returning an error Outcome, Rocket routes the erroring request to the highest precedence catcher among all the catchers that match. See Catcher::matches() for details on matching. Precedence is determined by the catcher’s base, which is provided as the first argument to Rocket::register(). Catchers with more non-empty segments have a higher precedence.

Rocket provides built-in defaults, but default catchers can also be registered. A default catcher is a catcher with no explicit status code: None.

§Collisions

Two catchers are said to collide if there exists an error that matches both catchers. Colliding catchers present a routing ambiguity and are thus disallowed by Rocket. Because catchers can be constructed dynamically, collision checking is done at ignite time, after it becomes statically impossible to register any more catchers on an instance of Rocket.

§Built-In Default

Rocket’s provides a built-in default catcher that can handle all errors. It produces HTML or JSON, depending on the value of the Accept header. As such, catchers only need to be registered if an error needs to be handled in a custom fashion. The built-in default never conflicts with any user-registered catchers.

§Code Generation

Catchers should rarely be constructed or used directly. Instead, they are typically generated via the catch attribute, as follows:

#[macro_use] extern crate rocket;

use rocket::Request;
use rocket::http::Status;

#[catch(500)]
fn internal_error() -> &'static str {
    "Whoops! Looks like we messed up."
}

#[catch(404)]
fn not_found(req: &Request) -> String {
    format!("I couldn't find '{}'. Try something else?", req.uri())
}

#[catch(default)]
fn default(status: Status, req: &Request) -> String {
    format!("{} ({})", status, req.uri())
}

#[launch]
fn rocket() -> _ {
    rocket::build().register("/", catchers![internal_error, not_found, default])
}

A function decorated with #[catch] may take zero, one, or two arguments. It’s type signature must be one of the following, where R:Responder:

See the catch documentation for full details.

Fields§

§name: Option<Cow<'static, str>>

The name of this catcher, if one was given.

§code: Option<u16>

The HTTP status to match against if this route is not default.

§handler: Box<dyn Handler>

The catcher’s associated error handler.

Implementations§

Source§

impl Catcher

Source

pub fn new<S, H>(code: S, handler: H) -> Catcher
where S: Into<Option<u16>>, H: Handler,

Creates a catcher for the given status, or a default catcher if status is None, using the given error handler. This should only be used when routing manually.

§Examples
use rocket::request::Request;
use rocket::catcher::{Catcher, BoxFuture};
use rocket::response::Responder;
use rocket::http::Status;

fn handle_404<'r>(status: Status, req: &'r Request<'_>) -> BoxFuture<'r> {
   let res = (status, format!("404: {}", req.uri()));
   Box::pin(async move { res.respond_to(req) })
}

fn handle_500<'r>(_: Status, req: &'r Request<'_>) -> BoxFuture<'r> {
    Box::pin(async move{ "Whoops, we messed up!".respond_to(req) })
}

fn handle_default<'r>(status: Status, req: &'r Request<'_>) -> BoxFuture<'r> {
   let res = (status, format!("{}: {}", status, req.uri()));
   Box::pin(async move { res.respond_to(req) })
}

let not_found_catcher = Catcher::new(404, handle_404);
let internal_server_error_catcher = Catcher::new(500, handle_500);
let default_error_catcher = Catcher::new(None, handle_default);
§Panics

Panics if code is not in the HTTP status code error range [400, 600).

Source

pub fn base(&self) -> Path<'_>

Returns the mount point (base) of the catcher, which defaults to /.

§Example
use rocket::request::Request;
use rocket::catcher::{Catcher, BoxFuture};
use rocket::response::Responder;
use rocket::http::Status;

fn handle_404<'r>(status: Status, req: &'r Request<'_>) -> BoxFuture<'r> {
   let res = (status, format!("404: {}", req.uri()));
   Box::pin(async move { res.respond_to(req) })
}

let catcher = Catcher::new(404, handle_404);
assert_eq!(catcher.base(), "/");

let catcher = catcher.map_base(|base| format!("/foo/bar/{}", base)).unwrap();
assert_eq!(catcher.base(), "/foo/bar");
Source

pub fn rebase(self, base: Origin<'_>) -> Self

Prefix base to the current base in self.

If the the current base is /, then the base is replaced by base. Otherwise, base is prefixed to the existing base.

use rocket::request::Request;
use rocket::catcher::{Catcher, BoxFuture};
use rocket::response::Responder;
use rocket::http::Status;

fn handle_404<'r>(status: Status, req: &'r Request<'_>) -> BoxFuture<'r> {
   let res = (status, format!("404: {}", req.uri()));
   Box::pin(async move { res.respond_to(req) })
}

let catcher = Catcher::new(404, handle_404);
assert_eq!(catcher.base(), "/");

// Since the base is `/`, rebasing replaces the base.
let rebased = catcher.rebase(uri!("/boo"));
assert_eq!(rebased.base(), "/boo");

// Now every rebase prefixes.
let rebased = rebased.rebase(uri!("/base"));
assert_eq!(rebased.base(), "/base/boo");

// Note that trailing slashes have no effect and are thus removed:
let catcher = Catcher::new(404, handle_404);
let rebased = catcher.rebase(uri!("/boo/"));
assert_eq!(rebased.base(), "/boo");
Source

pub fn map_base<'a, F>(self, mapper: F) -> Result<Self, Error<'static>>
where F: FnOnce(Origin<'a>) -> String,

Maps the base of this catcher using mapper, returning a new Catcher with the returned base.

Note: Prefer to use Catcher::rebase() whenever possible!

mapper is called with the current base. The returned String is used as the new base if it is a valid URI. If the returned base URI contains a query, it is ignored. Returns an error if the base produced by mapper is not a valid origin URI.

§Example
use rocket::request::Request;
use rocket::catcher::{Catcher, BoxFuture};
use rocket::response::Responder;
use rocket::http::Status;

fn handle_404<'r>(status: Status, req: &'r Request<'_>) -> BoxFuture<'r> {
   let res = (status, format!("404: {}", req.uri()));
   Box::pin(async move { res.respond_to(req) })
}

let catcher = Catcher::new(404, handle_404);
assert_eq!(catcher.base(), "/");

let catcher = catcher.map_base(|_| format!("/bar")).unwrap();
assert_eq!(catcher.base(), "/bar");

let catcher = catcher.map_base(|base| format!("/foo{}", base)).unwrap();
assert_eq!(catcher.base(), "/foo/bar");

let catcher = catcher.map_base(|base| format!("/foo ? {}", base));
assert!(catcher.is_err());
Source§

impl Catcher

Source

pub fn collides_with(&self, other: &Self) -> bool

Returns true if self collides with other.

A collision between two catchers occurs when there exists a request and ensuing error that could match both catchers. That is, a routing ambiguity would ensue if both catchers were made available to the router.

Specifically, a collision occurs when two catchers:

  • Have the same base.
  • Have the same status code or are both default.

Collisions are symmetric: for any catchers a and b, a.collides_with(b) => b.collides_with(a).

§Example
use rocket::Catcher;

// Two catchers with the same status code and base collide.
let a = Catcher::new(404, handler).map_base(|_| format!("/foo")).unwrap();
let b = Catcher::new(404, handler).map_base(|_| format!("/foo")).unwrap();
assert!(a.collides_with(&b));

// Two catchers with a different base _do not_ collide.
let a = Catcher::new(404, handler);
let b = a.clone().map_base(|_| format!("/bar")).unwrap();
assert_eq!(a.base(), "/");
assert_eq!(b.base(), "/bar");
assert!(!a.collides_with(&b));

// Two catchers with a different codes _do not_ collide.
let a = Catcher::new(404, handler);
let b = Catcher::new(500, handler);
assert_eq!(a.base(), "/");
assert_eq!(b.base(), "/");
assert!(!a.collides_with(&b));

// A catcher _with_ a status code and one _without_ do not collide.
let a = Catcher::new(404, handler);
let b = Catcher::new(None, handler);
assert!(!a.collides_with(&b));
Source§

impl Catcher

Source

pub fn matches(&self, status: Status, request: &Request<'_>) -> bool

Returns true if self matches errors with status that occurred during request.

A match between a Catcher and a (Status, &Request) pair occurs when:

  • The catcher has the same code as status or is default.
  • The catcher’s base is a prefix of the request’s normalized URI.

For an error arising from a request to be routed to a particular catcher, that catcher must both match and have higher precedence than any other catcher that matches. In other words, a match is a necessary but insufficient condition to determine if a catcher will handle a particular error.

The precedence of a catcher is determined by:

  1. The number of complete segments in the catcher’s base.
  2. Whether the catcher is default or not.

Non-default routes, and routes with more complete segments in their base, have higher precedence.

§Example
use rocket::Catcher;
use rocket::http::Status;

// This catcher handles 404 errors with a base of `/`.
let a = Catcher::new(404, handler);

// This catcher handles 404 errors with a base of `/bar`.
let b = a.clone().map_base(|_| format!("/bar")).unwrap();

// Let's say `request` is `GET /` that 404s. The error matches only `a`:
let request = client.get("/");
assert!(a.matches(Status::NotFound, &request));
assert!(!b.matches(Status::NotFound, &request));

// Now `request` is a 404 `GET /bar`. The error matches `a` and `b`:
let request = client.get("/bar");
assert!(a.matches(Status::NotFound, &request));
assert!(b.matches(Status::NotFound, &request));

// Note that because `b`'s base' has more complete segments that `a's,
// Rocket would route the error to `b`, not `a`, even though both match.
let a_count = a.base().segments().filter(|s| !s.is_empty()).count();
let b_count = b.base().segments().filter(|s| !s.is_empty()).count();
assert!(b_count > a_count);

Trait Implementations§

Source§

impl Clone for Catcher

Source§

fn clone(&self) -> Catcher

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 Catcher

Source§

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

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

impl Default for Catcher

Source§

fn default() -> Self

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

impl Trace for Catcher

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> AsAny for T
where T: Any,

Source§

fn as_any_ref(&self) -> &(dyn Any + 'static)

Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Source§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Paint for T
where T: ?Sized,

Source§

fn fg(&self, value: Color) -> Painted<&T>

Returns a styled value derived from self with the foreground set to value.

This method should be used rarely. Instead, prefer to use color-specific builder methods like red() and green(), which have the same functionality but are pithier.

§Example

Set foreground color to white using fg():

use yansi::{Paint, Color};

painted.fg(Color::White);

Set foreground color to white using white().

use yansi::Paint;

painted.white();
Source§

fn primary(&self) -> Painted<&T>

Returns self with the fg() set to Color::Primary.

§Example
println!("{}", value.primary());
Source§

fn fixed(&self, color: u8) -> Painted<&T>

Returns self with the fg() set to Color::Fixed.

§Example
println!("{}", value.fixed(color));
Source§

fn rgb(&self, r: u8, g: u8, b: u8) -> Painted<&T>

Returns self with the fg() set to Color::Rgb.

§Example
println!("{}", value.rgb(r, g, b));
Source§

fn black(&self) -> Painted<&T>

Returns self with the fg() set to Color::Black.

§Example
println!("{}", value.black());
Source§

fn red(&self) -> Painted<&T>

Returns self with the fg() set to Color::Red.

§Example
println!("{}", value.red());
Source§

fn green(&self) -> Painted<&T>

Returns self with the fg() set to Color::Green.

§Example
println!("{}", value.green());
Source§

fn yellow(&self) -> Painted<&T>

Returns self with the fg() set to Color::Yellow.

§Example
println!("{}", value.yellow());
Source§

fn blue(&self) -> Painted<&T>

Returns self with the fg() set to Color::Blue.

§Example
println!("{}", value.blue());
Source§

fn magenta(&self) -> Painted<&T>

Returns self with the fg() set to Color::Magenta.

§Example
println!("{}", value.magenta());
Source§

fn cyan(&self) -> Painted<&T>

Returns self with the fg() set to Color::Cyan.

§Example
println!("{}", value.cyan());
Source§

fn white(&self) -> Painted<&T>

Returns self with the fg() set to Color::White.

§Example
println!("{}", value.white());
Source§

fn bright_black(&self) -> Painted<&T>

Returns self with the fg() set to Color::BrightBlack.

§Example
println!("{}", value.bright_black());
Source§

fn bright_red(&self) -> Painted<&T>

Returns self with the fg() set to Color::BrightRed.

§Example
println!("{}", value.bright_red());
Source§

fn bright_green(&self) -> Painted<&T>

Returns self with the fg() set to Color::BrightGreen.

§Example
println!("{}", value.bright_green());
Source§

fn bright_yellow(&self) -> Painted<&T>

Returns self with the fg() set to Color::BrightYellow.

§Example
println!("{}", value.bright_yellow());
Source§

fn bright_blue(&self) -> Painted<&T>

Returns self with the fg() set to Color::BrightBlue.

§Example
println!("{}", value.bright_blue());
Source§

fn bright_magenta(&self) -> Painted<&T>

Returns self with the fg() set to Color::BrightMagenta.

§Example
println!("{}", value.bright_magenta());
Source§

fn bright_cyan(&self) -> Painted<&T>

Returns self with the fg() set to Color::BrightCyan.

§Example
println!("{}", value.bright_cyan());
Source§

fn bright_white(&self) -> Painted<&T>

Returns self with the fg() set to Color::BrightWhite.

§Example
println!("{}", value.bright_white());
Source§

fn bg(&self, value: Color) -> Painted<&T>

Returns a styled value derived from self with the background set to value.

This method should be used rarely. Instead, prefer to use color-specific builder methods like on_red() and on_green(), which have the same functionality but are pithier.

§Example

Set background color to red using fg():

use yansi::{Paint, Color};

painted.bg(Color::Red);

Set background color to red using on_red().

use yansi::Paint;

painted.on_red();
Source§

fn on_primary(&self) -> Painted<&T>

Returns self with the bg() set to Color::Primary.

§Example
println!("{}", value.on_primary());
Source§

fn on_fixed(&self, color: u8) -> Painted<&T>

Returns self with the bg() set to Color::Fixed.

§Example
println!("{}", value.on_fixed(color));
Source§

fn on_rgb(&self, r: u8, g: u8, b: u8) -> Painted<&T>

Returns self with the bg() set to Color::Rgb.

§Example
println!("{}", value.on_rgb(r, g, b));
Source§

fn on_black(&self) -> Painted<&T>

Returns self with the bg() set to Color::Black.

§Example
println!("{}", value.on_black());
Source§

fn on_red(&self) -> Painted<&T>

Returns self with the bg() set to Color::Red.

§Example
println!("{}", value.on_red());
Source§

fn on_green(&self) -> Painted<&T>

Returns self with the bg() set to Color::Green.

§Example
println!("{}", value.on_green());
Source§

fn on_yellow(&self) -> Painted<&T>

Returns self with the bg() set to Color::Yellow.

§Example
println!("{}", value.on_yellow());
Source§

fn on_blue(&self) -> Painted<&T>

Returns self with the bg() set to Color::Blue.

§Example
println!("{}", value.on_blue());
Source§

fn on_magenta(&self) -> Painted<&T>

Returns self with the bg() set to Color::Magenta.

§Example
println!("{}", value.on_magenta());
Source§

fn on_cyan(&self) -> Painted<&T>

Returns self with the bg() set to Color::Cyan.

§Example
println!("{}", value.on_cyan());
Source§

fn on_white(&self) -> Painted<&T>

Returns self with the bg() set to Color::White.

§Example
println!("{}", value.on_white());
Source§

fn on_bright_black(&self) -> Painted<&T>

Returns self with the bg() set to Color::BrightBlack.

§Example
println!("{}", value.on_bright_black());
Source§

fn on_bright_red(&self) -> Painted<&T>

Returns self with the bg() set to Color::BrightRed.

§Example
println!("{}", value.on_bright_red());
Source§

fn on_bright_green(&self) -> Painted<&T>

Returns self with the bg() set to Color::BrightGreen.

§Example
println!("{}", value.on_bright_green());
Source§

fn on_bright_yellow(&self) -> Painted<&T>

Returns self with the bg() set to Color::BrightYellow.

§Example
println!("{}", value.on_bright_yellow());
Source§

fn on_bright_blue(&self) -> Painted<&T>

Returns self with the bg() set to Color::BrightBlue.

§Example
println!("{}", value.on_bright_blue());
Source§

fn on_bright_magenta(&self) -> Painted<&T>

Returns self with the bg() set to Color::BrightMagenta.

§Example
println!("{}", value.on_bright_magenta());
Source§

fn on_bright_cyan(&self) -> Painted<&T>

Returns self with the bg() set to Color::BrightCyan.

§Example
println!("{}", value.on_bright_cyan());
Source§

fn on_bright_white(&self) -> Painted<&T>

Returns self with the bg() set to Color::BrightWhite.

§Example
println!("{}", value.on_bright_white());
Source§

fn attr(&self, value: Attribute) -> Painted<&T>

Enables the styling Attribute value.

This method should be used rarely. Instead, prefer to use attribute-specific builder methods like bold() and underline(), which have the same functionality but are pithier.

§Example

Make text bold using attr():

use yansi::{Paint, Attribute};

painted.attr(Attribute::Bold);

Make text bold using using bold().

use yansi::Paint;

painted.bold();
Source§

fn bold(&self) -> Painted<&T>

Returns self with the attr() set to Attribute::Bold.

§Example
println!("{}", value.bold());
Source§

fn dim(&self) -> Painted<&T>

Returns self with the attr() set to Attribute::Dim.

§Example
println!("{}", value.dim());
Source§

fn italic(&self) -> Painted<&T>

Returns self with the attr() set to Attribute::Italic.

§Example
println!("{}", value.italic());
Source§

fn underline(&self) -> Painted<&T>

Returns self with the attr() set to Attribute::Underline.

§Example
println!("{}", value.underline());

Returns self with the attr() set to Attribute::Blink.

§Example
println!("{}", value.blink());

Returns self with the attr() set to Attribute::RapidBlink.

§Example
println!("{}", value.rapid_blink());
Source§

fn invert(&self) -> Painted<&T>

Returns self with the attr() set to Attribute::Invert.

§Example
println!("{}", value.invert());
Source§

fn conceal(&self) -> Painted<&T>

Returns self with the attr() set to Attribute::Conceal.

§Example
println!("{}", value.conceal());
Source§

fn strike(&self) -> Painted<&T>

Returns self with the attr() set to Attribute::Strike.

§Example
println!("{}", value.strike());
Source§

fn quirk(&self, value: Quirk) -> Painted<&T>

Enables the yansi Quirk value.

This method should be used rarely. Instead, prefer to use quirk-specific builder methods like mask() and wrap(), which have the same functionality but are pithier.

§Example

Enable wrapping using .quirk():

use yansi::{Paint, Quirk};

painted.quirk(Quirk::Wrap);

Enable wrapping using wrap().

use yansi::Paint;

painted.wrap();
Source§

fn mask(&self) -> Painted<&T>

Returns self with the quirk() set to Quirk::Mask.

§Example
println!("{}", value.mask());
Source§

fn wrap(&self) -> Painted<&T>

Returns self with the quirk() set to Quirk::Wrap.

§Example
println!("{}", value.wrap());
Source§

fn linger(&self) -> Painted<&T>

Returns self with the quirk() set to Quirk::Linger.

§Example
println!("{}", value.linger());
Source§

fn clear(&self) -> Painted<&T>

👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear(). The clear() method will be removed in a future release.

Returns self with the quirk() set to Quirk::Clear.

§Example
println!("{}", value.clear());
Source§

fn resetting(&self) -> Painted<&T>

Returns self with the quirk() set to Quirk::Resetting.

§Example
println!("{}", value.resetting());
Source§

fn bright(&self) -> Painted<&T>

Returns self with the quirk() set to Quirk::Bright.

§Example
println!("{}", value.bright());
Source§

fn on_bright(&self) -> Painted<&T>

Returns self with the quirk() set to Quirk::OnBright.

§Example
println!("{}", value.on_bright());
Source§

fn whenever(&self, value: Condition) -> Painted<&T>

Conditionally enable styling based on whether the Condition value applies. Replaces any previous condition.

See the crate level docs for more details.

§Example

Enable styling painted only when both stdout and stderr are TTYs:

use yansi::{Paint, Condition};

painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);
Source§

fn new(self) -> Painted<Self>
where Self: Sized,

Create a new Painted with a default Style. Read more
Source§

fn paint<S>(&self, style: S) -> Painted<&Self>
where S: Into<Style>,

Apply a style wholesale to self. Any previous style is replaced. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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>,

Source§

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.
Source§

impl<T, U> Upcast<T> for U
where T: UpcastFrom<U>,

Source§

fn upcast(self) -> T

Source§

impl<T, B> UpcastFrom<Counter<T, B>> for T

Source§

fn upcast_from(value: Counter<T, B>) -> T

Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more