51: feat: allow serialization of unit structs r=nox a=fdehau

fix #50 

Co-authored-by: Florian Dehau <work@fdehau.com>
This commit is contained in:
bors[bot] 2019-07-30 07:41:19 +00:00
commit 4250a6bcd9
2 changed files with 10 additions and 2 deletions

View File

@ -227,12 +227,12 @@ where
Err(Error::top_level()) Err(Error::top_level())
} }
/// Returns an error. /// Returns `Ok`.
fn serialize_unit_struct( fn serialize_unit_struct(
self, self,
_name: &'static str, _name: &'static str,
) -> Result<Self::Ok, Error> { ) -> Result<Self::Ok, Error> {
Err(Error::top_level()) Ok(self.urlencoder)
} }
/// Returns an error. /// Returns an error.

View File

@ -73,3 +73,11 @@ fn serialize_unit_enum() {
Ok("one=A&two=B&three=C".to_owned()) 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()));
}