Merge #68
68: Allow serialization of unit type r=nox a=maxv-rust That changes provides support for unit type serialization. It may looks like it doesn't make sense to serialize `()`. Unfortunately that kind of serialization may be necessary for generic structures where one of generic argument may be `()`. Closes #69 Co-authored-by: MaxV <60802079+maxv-rust@users.noreply.github.com>
This commit is contained in:
commit
ab6f3ce278
@ -230,9 +230,9 @@ where
|
|||||||
Err(Error::top_level())
|
Err(Error::top_level())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns an error.
|
/// Returns `Ok`.
|
||||||
fn serialize_unit(self) -> Result<Self::Ok, Error> {
|
fn serialize_unit(self) -> Result<Self::Ok, Error> {
|
||||||
Err(Error::top_level())
|
Ok(self.urlencoder)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns `Ok`.
|
/// Returns `Ok`.
|
||||||
|
@ -83,3 +83,8 @@ fn deserialize_unit_enum() {
|
|||||||
Ok(result)
|
Ok(result)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn deserialize_unit_type() {
|
||||||
|
assert_eq!(serde_urlencoded::from_str(""), Ok(()));
|
||||||
|
}
|
||||||
|
@ -81,3 +81,8 @@ struct Unit;
|
|||||||
fn serialize_unit_struct() {
|
fn serialize_unit_struct() {
|
||||||
assert_eq!(serde_urlencoded::to_string(Unit), Ok("".to_owned()));
|
assert_eq!(serde_urlencoded::to_string(Unit), Ok("".to_owned()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn serialize_unit_type() {
|
||||||
|
assert_eq!(serde_urlencoded::to_string(()), Ok("".to_owned()));
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user