Skip to main content

path_param

Macro path_param 

Source
macro_rules! path_param {
    ($($t:ty),* $(,)?) => { ... };
}
Expand description

Admit a custom newtype as a Path parameter. The type must implement FromStr with a Display error; a parse failure maps to the same JC0400 invalid-path-parameter error the built-in impls produce.

#[derive(Debug)]
struct LeadId(i64);
impl std::str::FromStr for LeadId {
    type Err = std::num::ParseIntError;
    fn from_str(s: &str) -> Result<Self, Self::Err> { Ok(LeadId(s.parse()?)) }
}
jerrycan::path_param!(LeadId);