1
0
Fork 0
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:
marcelbuesing 2018-07-03 10:32:20 +02:00
parent b6d26c9faf
commit e225825387
No known key found for this signature in database
GPG key ID: E51C4F8A2B7FF43E

View file

@ -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
);
}
} }