macro_rules! literal {
($lit:literal) => { ... };
{
$( $vis:vis $name:ident: $lit:literal; )+
} => { ... };
}Expand description
Creates a literal value, or declares one or more named literal types.
ยงExamples
// Creates an ad-hoc literal value.
foo().with_context(literal!("file not found"))?;
// Defines a list of typed literals.
literal!{
pub NotFound: "file not found";
pub InternalError: "internal error";
}
foo().with_context(NotFound)?;
foo().with_context_ty::<InternalError>()?;