Skip to content

Commit 9e952e2

Browse files
authored
Remove any feature = "std" gating
A `std` feature cannot yet be introduces, so these would otherwise break the code.
1 parent c9d9226 commit 9e952e2

File tree

8 files changed

+1
-41
lines changed

8 files changed

+1
-41
lines changed

serde_with/src/de/const_arrays.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ use crate::utils::{MapIter, SeqIter};
33
use alloc::{borrow::Cow, boxed::Box, collections::BTreeMap, string::String, vec::Vec};
44
use core::{convert::TryInto, fmt, mem::MaybeUninit};
55
use serde::de::*;
6-
#[cfg(feature = "std")]
76
use std::collections::HashMap;
87

98
// TODO this should probably be moved into the utils module when const generics are available for MSRV
@@ -146,7 +145,6 @@ macro_rules! tuple_seq_as_map_impl_intern {
146145
}
147146
}
148147
tuple_seq_as_map_impl_intern!([(K, V); N], BTreeMap<KAs, VAs>);
149-
#[cfg(feature = "std")]
150148
tuple_seq_as_map_impl_intern!([(K, V); N], HashMap<KAs, VAs>);
151149

152150
impl<'de, const N: usize> DeserializeAs<'de, [u8; N]> for Bytes {

serde_with/src/de/impls.rs

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,18 @@ use alloc::{
1414
sync::{Arc, Weak as ArcWeak},
1515
vec::Vec,
1616
};
17-
#[cfg(any(feature = "indexmap", feature = "std"))]
18-
use core::hash::{BuildHasher, Hash};
1917
use core::{
2018
cell::{Cell, RefCell},
2119
convert::TryInto,
2220
fmt::{self, Display},
21+
hash::{BuildHasher, Hash},
2322
iter::FromIterator,
2423
str::FromStr,
2524
time::Duration,
2625
};
2726
#[cfg(feature = "indexmap")]
2827
use indexmap_crate::{IndexMap, IndexSet};
2928
use serde::de::*;
30-
#[cfg(feature = "std")]
3129
use std::{
3230
collections::{HashMap, HashSet},
3331
sync::{Mutex, RwLock},
@@ -182,7 +180,6 @@ where
182180
}
183181
}
184182

185-
#[cfg(feature = "std")]
186183
impl<'de, T, U> DeserializeAs<'de, Mutex<T>> for Mutex<U>
187184
where
188185
U: DeserializeAs<'de, T>,
@@ -197,7 +194,6 @@ where
197194
}
198195
}
199196

200-
#[cfg(feature = "std")]
201197
impl<'de, T, U> DeserializeAs<'de, RwLock<T>> for RwLock<U>
202198
where
203199
U: DeserializeAs<'de, T>,
@@ -313,7 +309,6 @@ seq_impl!(
313309
push
314310
);
315311
seq_impl!(BTreeSet<T: Ord>, seq, BTreeSet::new(), insert);
316-
#[cfg(feature = "std")]
317312
seq_impl!(
318313
HashSet<T: Eq + Hash, S: BuildHasher + Default>,
319314
seq,
@@ -407,7 +402,6 @@ map_impl!(
407402
BTreeMap<K: Ord, V>,
408403
map,
409404
BTreeMap::new());
410-
#[cfg(feature = "std")]
411405
map_impl!(
412406
HashMap<K: Eq + Hash, V, S: BuildHasher + Default>,
413407
map,
@@ -537,7 +531,6 @@ macro_rules! map_as_tuple_seq {
537531
};
538532
}
539533
map_as_tuple_seq!(BTreeMap<K: Ord, V>);
540-
#[cfg(feature = "std")]
541534
map_as_tuple_seq!(HashMap<K: Eq + Hash, V>);
542535
#[cfg(feature = "indexmap")]
543536
map_as_tuple_seq!(IndexMap<K: Eq + Hash, V>);
@@ -704,7 +697,6 @@ macro_rules! tuple_seq_as_map_impl_intern {
704697
macro_rules! tuple_seq_as_map_impl {
705698
($($tyorig:ident < (K $(: $($kbound:ident $(+)?)+)?, V $(: $($vbound:ident $(+)?)+)?)> $(,)?)+) => {$(
706699
tuple_seq_as_map_impl_intern!($tyorig < (K $(: $($kbound +)+)?, V $(: $($vbound +)+)?) >, BTreeMap<KAs, VAs>);
707-
#[cfg(feature = "std")]
708700
tuple_seq_as_map_impl_intern!($tyorig < (K $(: $($kbound +)+)?, V $(: $($vbound +)+)?) >, HashMap<KAs, VAs>);
709701
)+}
710702
}
@@ -716,7 +708,6 @@ tuple_seq_as_map_impl! {
716708
Vec<(K, V)>,
717709
VecDeque<(K, V)>,
718710
}
719-
#[cfg(feature = "std")]
720711
tuple_seq_as_map_impl!(HashSet<(K: Eq + Hash, V: Eq + Hash)>);
721712
#[cfg(feature = "indexmap")]
722713
tuple_seq_as_map_impl!(IndexSet<(K: Eq + Hash, V: Eq + Hash)>);
@@ -775,7 +766,6 @@ macro_rules! tuple_seq_as_map_option_impl {
775766
)+}
776767
}
777768
tuple_seq_as_map_option_impl!(BTreeMap);
778-
#[cfg(feature = "std")]
779769
tuple_seq_as_map_option_impl!(HashMap);
780770

781771
impl<'de, T, TAs> DeserializeAs<'de, T> for DefaultOnError<TAs>
@@ -903,7 +893,6 @@ use_signed_duration!(
903893
}
904894
);
905895

906-
#[cfg(feature = "std")]
907896
use_signed_duration!(
908897
TimestampSeconds DurationSeconds,
909898
TimestampMilliSeconds DurationMilliSeconds,
@@ -917,7 +906,6 @@ use_signed_duration!(
917906
{FORMAT, Flexible => FORMAT: Format}
918907
}
919908
);
920-
#[cfg(feature = "std")]
921909
use_signed_duration!(
922910
TimestampSecondsWithFrac DurationSecondsWithFrac,
923911
TimestampMilliSecondsWithFrac DurationMilliSecondsWithFrac,

serde_with/src/duplicate_key_impls/error_on_duplicate.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
use alloc::collections::{BTreeMap, BTreeSet};
2-
#[cfg(any(feature = "indexmap", feature = "std"))]
32
use core::hash::{BuildHasher, Hash};
43
#[cfg(feature = "indexmap")]
54
use indexmap_crate::{IndexMap, IndexSet};
6-
#[cfg(feature = "std")]
75
use std::collections::{HashMap, HashSet};
86

97
pub trait PreventDuplicateInsertsSet<T> {
@@ -20,7 +18,6 @@ pub trait PreventDuplicateInsertsMap<K, V> {
2018
fn insert(&mut self, key: K, value: V) -> bool;
2119
}
2220

23-
#[cfg(feature = "std")]
2421
impl<T, S> PreventDuplicateInsertsSet<T> for HashSet<T, S>
2522
where
2623
T: Eq + Hash,
@@ -75,7 +72,6 @@ where
7572
}
7673
}
7774

78-
#[cfg(feature = "std")]
7975
impl<K, V, S> PreventDuplicateInsertsMap<K, V> for HashMap<K, V, S>
8076
where
8177
K: Eq + Hash,

serde_with/src/duplicate_key_impls/first_value_wins.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
use alloc::collections::{BTreeMap, BTreeSet};
2-
#[cfg(any(feature = "indexmap", feature = "std"))]
32
use core::hash::{BuildHasher, Hash};
43
#[cfg(feature = "indexmap")]
54
use indexmap_crate::IndexMap;
6-
#[cfg(feature = "std")]
75
use std::collections::{HashMap, HashSet};
86

97
#[deprecated = "This is serde's default behavior."]
@@ -21,7 +19,6 @@ pub trait DuplicateInsertsFirstWinsMap<K, V> {
2119
fn insert(&mut self, key: K, value: V);
2220
}
2321

24-
#[cfg(feature = "std")]
2522
#[allow(deprecated)]
2623
impl<T, S> DuplicateInsertsFirstWinsSet<T> for HashSet<T, S>
2724
where
@@ -60,7 +57,6 @@ where
6057
}
6158
}
6259

63-
#[cfg(feature = "std")]
6460
impl<K, V, S> DuplicateInsertsFirstWinsMap<K, V> for HashMap<K, V, S>
6561
where
6662
K: Eq + Hash,

serde_with/src/duplicate_key_impls/last_value_wins.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
use alloc::collections::BTreeSet;
2-
#[cfg(any(feature = "indexmap", feature = "std"))]
32
use core::hash::{BuildHasher, Hash};
43
#[cfg(feature = "indexmap")]
54
use indexmap_crate::IndexSet;
6-
#[cfg(feature = "std")]
75
use std::collections::HashSet;
86

97
pub trait DuplicateInsertsLastWinsSet<T> {
@@ -13,7 +11,6 @@ pub trait DuplicateInsertsLastWinsSet<T> {
1311
fn replace(&mut self, value: T);
1412
}
1513

16-
#[cfg(feature = "std")]
1714
impl<T, S> DuplicateInsertsLastWinsSet<T> for HashSet<T, S>
1815
where
1916
T: Eq + Hash,

serde_with/src/ser/const_arrays.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use super::*;
22
use alloc::{borrow::Cow, boxed::Box, collections::BTreeMap};
3-
#[cfg(feature = "std")]
43
use std::collections::HashMap;
54

65
impl<T, As, const N: usize> SerializeAs<[T; N]> for [As; N]
@@ -43,7 +42,6 @@ macro_rules! tuple_seq_as_map_impl_intern {
4342
};
4443
}
4544
tuple_seq_as_map_impl_intern!([(K, V); N], BTreeMap<K, V>);
46-
#[cfg(feature = "std")]
4745
tuple_seq_as_map_impl_intern!([(K, V); N], HashMap<K, V>);
4846

4947
impl<const N: usize> SerializeAs<[u8; N]> for Bytes {

serde_with/src/ser/impls.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ use core::{
2020
#[cfg(feature = "indexmap")]
2121
use indexmap_crate::{IndexMap, IndexSet};
2222
use serde::ser::Error;
23-
#[cfg(feature = "std")]
2423
use std::{
2524
collections::{HashMap, HashSet},
2625
sync::{Mutex, RwLock},
@@ -163,7 +162,6 @@ where
163162
}
164163
}
165164

166-
#[cfg(feature = "std")]
167165
impl<T, U> SerializeAs<Mutex<T>> for Mutex<U>
168166
where
169167
U: SerializeAs<T>,
@@ -179,7 +177,6 @@ where
179177
}
180178
}
181179

182-
#[cfg(feature = "std")]
183180
impl<T, U> SerializeAs<RwLock<T>> for RwLock<U>
184181
where
185182
U: SerializeAs<T>,
@@ -239,7 +236,6 @@ type Slice<T> = [T];
239236
seq_impl!(BinaryHeap<T>);
240237
seq_impl!(BoxedSlice<T>);
241238
seq_impl!(BTreeSet<T>);
242-
#[cfg(feature = "std")]
243239
seq_impl!(HashSet<T, H: Sized>);
244240
seq_impl!(LinkedList<T>);
245241
seq_impl!(Slice<T>);
@@ -268,7 +264,6 @@ macro_rules! map_impl {
268264
}
269265

270266
map_impl!(BTreeMap<K, V>);
271-
#[cfg(feature = "std")]
272267
map_impl!(HashMap<K, V, H: Sized>);
273268
#[cfg(feature = "indexmap")]
274269
map_impl!(IndexMap<K, V, H: Sized>);
@@ -334,7 +329,6 @@ macro_rules! map_as_tuple_seq {
334329
}
335330
map_as_tuple_seq!(BTreeMap<K, V>);
336331
// TODO HashMap with a custom hasher support would be better, but results in "unconstrained type parameter"
337-
#[cfg(feature = "std")]
338332
map_as_tuple_seq!(HashMap<K, V>);
339333
#[cfg(feature = "indexmap")]
340334
map_as_tuple_seq!(IndexMap<K, V>);
@@ -416,7 +410,6 @@ macro_rules! tuple_seq_as_map_impl_intern {
416410
macro_rules! tuple_seq_as_map_impl {
417411
($($ty:ty $(,)?)+) => {$(
418412
tuple_seq_as_map_impl_intern!($ty, BTreeMap<K, V>);
419-
#[cfg(feature = "std")]
420413
tuple_seq_as_map_impl_intern!($ty, HashMap<K, V>);
421414
)+}
422415
}
@@ -429,7 +422,6 @@ tuple_seq_as_map_impl! {
429422
Vec<(K, V)>,
430423
VecDeque<(K, V)>,
431424
}
432-
#[cfg(feature = "std")]
433425
tuple_seq_as_map_impl!(HashSet<(K, V)>);
434426
#[cfg(feature = "indexmap")]
435427
tuple_seq_as_map_impl!(IndexSet<(K, V)>);
@@ -538,7 +530,6 @@ use_signed_duration!(
538530
}
539531
);
540532

541-
#[cfg(feature = "std")]
542533
use_signed_duration!(
543534
TimestampSeconds DurationSeconds,
544535
TimestampMilliSeconds DurationMilliSeconds,
@@ -551,7 +542,6 @@ use_signed_duration!(
551542
{String, STRICTNESS => STRICTNESS: Strictness}
552543
}
553544
);
554-
#[cfg(feature = "std")]
555545
use_signed_duration!(
556546
TimestampSecondsWithFrac DurationSecondsWithFrac,
557547
TimestampMilliSecondsWithFrac DurationMilliSecondsWithFrac,

serde_with/src/utils/duration.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ use serde::{
1616
de::{self, Unexpected, Visitor},
1717
ser, Deserialize, Deserializer, Serialize, Serializer,
1818
};
19-
#[cfg(feature = "std")]
2019
use std::time::SystemTime;
2120

2221
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
@@ -66,7 +65,6 @@ impl DurationSigned {
6665
Self { sign, duration }
6766
}
6867

69-
#[cfg(feature = "std")]
7068
pub(crate) fn to_system_time<'de, D>(self) -> Result<SystemTime, D::Error>
7169
where
7270
D: Deserializer<'de>,
@@ -100,7 +98,6 @@ impl From<&Duration> for DurationSigned {
10098
}
10199
}
102100

103-
#[cfg(feature = "std")]
104101
impl From<&SystemTime> for DurationSigned {
105102
fn from(time: &SystemTime) -> Self {
106103
match time.duration_since(SystemTime::UNIX_EPOCH) {

0 commit comments

Comments
 (0)