Add support for boolean values
Merge #5 a=@mre r=@nox ________________________________________________________________________
This commit is contained in:
commit
87e0352ead
@ -51,8 +51,8 @@ impl<'key, 'target, Target> Serializer
|
|||||||
type StructState = ();
|
type StructState = ();
|
||||||
type StructVariantState = ();
|
type StructVariantState = ();
|
||||||
|
|
||||||
fn serialize_bool(&mut self, _v: bool) -> Result<(), Error> {
|
fn serialize_bool(&mut self, v: bool) -> Result<(), Error> {
|
||||||
Err(Error::unsupported_value())
|
self.append_pair(if v { "true" } else { "false" })
|
||||||
}
|
}
|
||||||
|
|
||||||
fn serialize_isize(&mut self, v: isize) -> Result<(), Error> {
|
fn serialize_isize(&mut self, v: isize) -> Result<(), Error> {
|
||||||
|
@ -25,3 +25,27 @@ fn serialize_option_map_string() {
|
|||||||
serde_urlencoded::to_string(params),
|
serde_urlencoded::to_string(params),
|
||||||
Ok("first=hello&last=world".to_owned()));
|
Ok("first=hello&last=world".to_owned()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn serialize_option_map_bool() {
|
||||||
|
let params = &[
|
||||||
|
("one", Some(true)),
|
||||||
|
("two", Some(false))
|
||||||
|
];
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
serde_urlencoded::to_string(params),
|
||||||
|
Ok("one=true&two=false".to_owned()));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn serialize_map_bool() {
|
||||||
|
let params = &[
|
||||||
|
("one", true),
|
||||||
|
("two", false)
|
||||||
|
];
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
serde_urlencoded::to_string(params),
|
||||||
|
Ok("one=true&two=false".to_owned()));
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user