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 = "indexmap_1")]
10use indexmap_1::IndexMap;
11#[cfg(feature = "indexmap_2")]
12use indexmap_2::IndexMap as IndexMap2;
13
14impl<T, U, I> SerializeAs<Vec<T>> for VecSkipError<U, I>
15where
16 U: SerializeAs<T>,
17{
18 fn serialize_as<S>(source: &Vec<T>, serializer: S) -> Result<S::Ok, S::Error>
19 where
20 S: Serializer,
21 {
22 Vec::<U>::serialize_as(source, serializer)
23 }
24}
25
26macro_rules! map_skip_error_handling {
27 ($tyorig:ident < K, V $(, $typaram:ident : $bound:ident)* >) => {
28 impl<K, KAs, V, VAs, I $(, $typaram)*> SerializeAs<$tyorig<K, V $(, $typaram)*>> for MapSkipError<KAs, VAs, I>
29 where
30 KAs: SerializeAs<K>,
31 VAs: SerializeAs<V>,
32 $($typaram: ?Sized + $bound,)*
33 {
34 fn serialize_as<S>(value: &$tyorig<K, V $(, $typaram)*>, serializer: S) -> Result<S::Ok, S::Error>
35 where
36 S: Serializer,
37 {
38 <$tyorig<KAs, VAs $(, $typaram)*>>::serialize_as(value, serializer)
39 }
40 }
41 }
42}
43foreach_map!(map_skip_error_handling);