You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
use serde::{Serialize,Serializer};#[derive(Serialize)]structStruct{#[serde(serialize_with = "vec_first_element")]vec:Vec<Self>,// works if written as Vec<Struct>}fnvec_first_element<S>(vec:&Vec<Struct>,serializer:S) -> Result<S::Ok,S::Error>whereS:Serializer,{
vec.first().serialize(serializer)}
error[E0308]: mismatched types --> src/main.rs:3:10 |3 | #[derive(Serialize)] | ^^^^^^^^^ expected struct `__SerializeWith`, found struct `Struct` | = note: expected reference `&Vec<__SerializeWith<'_>>` found reference `&Vec<Struct>` = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)error[E0308]: mismatched types --> src/main.rs:3:10 |3 | #[derive(Serialize)] | ^^^^^^^^^ expected struct `Struct`, found struct `__SerializeWith` | = note: expected reference `&Vec<Struct>` found reference `&'__a Vec<__SerializeWith<'__a>>` = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
The text was updated successfully, but these errors were encountered:
Closely related to #1506, #1565, #1830.
The text was updated successfully, but these errors were encountered: