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