serde_with/ser/
skip_error.rs1use super::impls::macros::foreach_map;
2use crate::prelude::*;
3#[cfg(feature = "hashbrown_0_14")]
4use hashbrown_0_14::HashMap as HashbrownMap014;
5#[cfg(feature = "hashbrown_0_15")]
6use hashbrown_0_15::HashMap as HashbrownMap015;
7#[cfg(feature = "hashbrown_0_16")]
8use hashbrown_0_16::HashMap as HashbrownMap016;
9#[cfg(feature = "hashbrown_0_17")]
10use hashbrown_0_17::HashMap as HashbrownMap017;
11#[cfg(feature = "indexmap_1")]
12use indexmap_1::IndexMap;
13#[cfg(feature = "indexmap_2")]
14use indexmap_2::IndexMap as IndexMap2;
15
16impl<T, U, I> SerializeAs<Vec<T>> for VecSkipError<U, I>
17where
18 U: SerializeAs<T>,
19{
20 fn serialize_as<S>(source: &Vec<T>, serializer: S) -> Result<S::Ok, S::Error>
21 where
22 S: Serializer,
23 {
24 Vec::<U>::serialize_as(source, serializer)
25 }
26}
27
28macro_rules! map_skip_error_handling {
29 ($tyorig:ident < K, V $(, $typaram:ident : $bound:ident)* >) => {
30 impl<K, KAs, V, VAs, I $(, $typaram)*> SerializeAs<$tyorig<K, V $(, $typaram)*>> for MapSkipError<KAs, VAs, I>
31 where
32 KAs: SerializeAs<K>,
33 VAs: SerializeAs<V>,
34 $($typaram: ?Sized + $bound,)*
35 {
36 fn serialize_as<S>(value: &$tyorig<K, V $(, $typaram)*>, serializer: S) -> Result<S::Ok, S::Error>
37 where
38 S: Serializer,
39 {
40 <$tyorig<KAs, VAs $(, $typaram)*>>::serialize_as(value, serializer)
41 }
42 }
43 }
44}
45foreach_map!(map_skip_error_handling);