Macro rocket::catchers[][src]

catchers!() { /* proc-macro */ }

Generates a Vec of Catchers from a set of catcher paths.

The catchers! macro expands a list of catcher paths into a Vec of their corresponding Catcher structures. For example, given the following catchers:

#[catch(404)]
fn not_found() { /* .. */ }

mod inner {
    #[catch(400)]
    pub fn unauthorized() { /* .. */ }
}

#[catch(default)]
fn default_catcher() { /* .. */ }

The catchers! macro can be used as:

let my_catchers = catchers![not_found, inner::unauthorized, default_catcher];
assert_eq!(my_catchers.len(), 3);

let not_found = &my_catchers[0];
assert_eq!(not_found.code, Some(404));

let unauthorized = &my_catchers[1];
assert_eq!(unauthorized.code, Some(400));

let default = &my_catchers[2];
assert_eq!(default.code, None);

The grammar for catchers! is defined as:

catchers := PATH (',' PATH)*

PATH := a path, as defined by Rust