Add regression test for issue 1969

This commit is contained in:
David Tolnay 2021-01-25 13:25:53 -08:00
parent b054ea4105
commit 6699b0bc40
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82

View File

@ -7,6 +7,7 @@
#![allow(
unknown_lints,
mixed_script_confusables,
clippy::ptr_arg,
clippy::trivially_copy_pass_by_ref
)]
@ -735,6 +736,12 @@ fn test_gen() {
#[serde(borrow = "'a")]
f: mac!(Cow<'a, str>),
}
#[derive(Serialize)]
struct Struct {
#[serde(serialize_with = "vec_first_element")]
vec: Vec<Self>,
}
}
//////////////////////////////////////////////////////////////////////////
@ -808,3 +815,11 @@ where
pub fn is_zero(n: &u8) -> bool {
*n == 0
}
fn vec_first_element<T, S>(vec: &Vec<T>, serializer: S) -> StdResult<S::Ok, S::Error>
where
T: Serialize,
S: Serializer,
{
vec.first().serialize(serializer)
}