mirror of
https://gitee.com/openharmony/third_party_rust_serde
synced 2024-11-23 06:50:23 +00:00
Add regression test for issue 1969
This commit is contained in:
parent
b054ea4105
commit
6699b0bc40
@ -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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user