mirror of
https://github.com/actix/actix-web.git
synced 2024-12-18 14:16:47 +00:00
implement FromParam for bool
This commit is contained in:
parent
b6d26c9faf
commit
e225825387
1 changed files with 13 additions and 0 deletions
13
src/param.rs
13
src/param.rs
|
@ -240,6 +240,7 @@ macro_rules! FROM_STR {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FROM_STR!(bool);
|
||||||
FROM_STR!(u8);
|
FROM_STR!(u8);
|
||||||
FROM_STR!(u16);
|
FROM_STR!(u16);
|
||||||
FROM_STR!(u32);
|
FROM_STR!(u32);
|
||||||
|
@ -296,4 +297,16 @@ mod tests {
|
||||||
Ok(PathBuf::from_iter(vec!["seg2"]))
|
Ok(PathBuf::from_iter(vec!["seg2"]))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_from_param() {
|
||||||
|
assert_eq!(
|
||||||
|
<bool as FromParam>::from_param("true").unwrap(),
|
||||||
|
true
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
<bool as FromParam>::from_param("false").unwrap(),
|
||||||
|
false
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue