Trait rocket::http::uri::Ignorable

pub trait Ignorable<P>
where P: UriPart,
{ }
Expand description

Trait implemented by types that can be ignored in uri!.

When a parameter is explicitly ignored in uri! by supplying _ as the parameter’s value, that parameter’s type is required to implement this trait for the corresponding UriPart.

#[get("/item/<id>?<track>")]
fn get_item(id: i32, track: Option<u8>) { /* .. */ }

// Ignore the `track` parameter: `Option<u8>` must be `Ignorable`.
uri!(get_item: 100, _);
uri!(get_item: id = 100, track = _);

// Provide a value for `track`.
uri!(get_item: 100, 4);
uri!(get_item: id = 100, track = 4);

§Implementations

Only Option<T> and Result<T, E> implement this trait. You may implement this trait for your own ignorable types as well:

use rocket::http::uri::{Ignorable, Query};

impl Ignorable<Query> for MyType { }

Implementations on Foreign Types§

§

impl<T> Ignorable<Query> for Option<T>

§

impl<T, E> Ignorable<Query> for Result<T, E>

Implementors§