Allow serialization of unit type

This commit is contained in:
MaxV 2020-04-08 23:02:57 -07:00
parent e659355313
commit f60e4fd093
3 changed files with 12 additions and 2 deletions

View File

@ -230,9 +230,9 @@ where
Err(Error::top_level())
}
/// Returns an error.
/// Returns `Ok`.
fn serialize_unit(self) -> Result<Self::Ok, Error> {
Err(Error::top_level())
Ok(self.urlencoder)
}
/// Returns `Ok`.

View File

@ -83,3 +83,8 @@ fn deserialize_unit_enum() {
Ok(result)
);
}
#[test]
fn deserialize_unit_type() {
assert_eq!(serde_urlencoded::from_str(""), Ok(()));
}

View File

@ -81,3 +81,8 @@ struct Unit;
fn serialize_unit_struct() {
assert_eq!(serde_urlencoded::to_string(Unit), Ok("".to_owned()));
}
#[test]
fn serialize_unit_type() {
assert_eq!(serde_urlencoded::to_string(()), Ok("".to_owned()));
}