Skip to content

Commit

Permalink
Add regression test for issue 1969
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Jan 25, 2021
1 parent b054ea4 commit 6699b0b
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions test_suite/tests/test_gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#![allow(
unknown_lints,
mixed_script_confusables,
clippy::ptr_arg,
clippy::trivially_copy_pass_by_ref
)]

Expand Down Expand Up @@ -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>,
}
}

//////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -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)
}

0 comments on commit 6699b0b

Please sign in to comment.