Debian Codegraph @

third_party/rust/serde_with/src/ser/skip_error.rs

raw
1 use super::impls::macros::foreach_map;
2 use crate::prelude::*;
3 #[cfg(feature = "hashbrown_0_14")]
4 use hashbrown_0_14::HashMap as HashbrownMap014;
5 #[cfg(feature = "hashbrown_0_15")]
6 use hashbrown_0_15::HashMap as HashbrownMap015;
7 #[cfg(feature = "indexmap_1")]
8 use indexmap_1::IndexMap;
9 #[cfg(feature = "indexmap_2")]
10 use indexmap_2::IndexMap as IndexMap2;
11
12 impl<T, U> SerializeAs<Vec<T>> for VecSkipError<U>
13 where
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
24 macro_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 }
41 foreach_map!(map_skip_error_handling);