feat: allow serialization of unit structs
This commit is contained in:
parent
643a206559
commit
76b45ee001
@ -227,12 +227,12 @@ where
|
||||
Err(Error::top_level())
|
||||
}
|
||||
|
||||
/// Returns an error.
|
||||
/// Returns `Ok`.
|
||||
fn serialize_unit_struct(
|
||||
self,
|
||||
_name: &'static str,
|
||||
) -> Result<Self::Ok, Error> {
|
||||
Err(Error::top_level())
|
||||
Ok(self.urlencoder)
|
||||
}
|
||||
|
||||
/// Returns an error.
|
||||
|
@ -73,3 +73,11 @@ fn serialize_unit_enum() {
|
||||
Ok("one=A&two=B&three=C".to_owned())
|
||||
);
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
struct Unit;
|
||||
|
||||
#[test]
|
||||
fn serialize_unit_struct() {
|
||||
assert_eq!(serde_urlencoded::to_string(Unit), Ok("".to_owned()));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user