16
16
//!
17
17
//! ## Optional features
18
18
//!
19
- //! ### `serde `
19
+ //! ### `std `
20
20
//!
21
- //! When this optional dependency is enabled, `SmallVec` implements the `serde::Serialize` and
22
- //! `serde::Deserialize` traits.
21
+ //! When this feature is enabled, traits available from `std` are implemented:
23
22
//!
24
- //! ### `write`
23
+ //! * `SmallVec<u8, _>` implements the [`std::io::Write`] trait.
24
+ //! * [`CollectionAllocErr`] implements [`std::error::Error`].
25
25
//!
26
- //! When this feature is enabled, `SmallVec<u8, _>` implements the `std::io::Write` trait.
27
26
//! This feature is not compatible with `#![no_std]` programs.
28
27
//!
28
+ //! ### `serde`
29
+ //!
30
+ //! When this optional dependency is enabled, `SmallVec` implements the `serde::Serialize` and
31
+ //! `serde::Deserialize` traits.
32
+ //!
29
33
//! ### `extract_if`
30
34
//!
31
35
//! **This feature is unstable.** It may change to match the unstable `extract_if` method in libstd.
62
66
#[ doc( hidden) ]
63
67
pub extern crate alloc;
64
68
65
- #[ cfg( any( test, feature = "write " ) ) ]
69
+ #[ cfg( any( test, feature = "std " ) ) ]
66
70
extern crate std;
67
71
68
72
#[ cfg( test) ]
@@ -93,7 +97,7 @@ use serde::{
93
97
de:: { Deserialize , Deserializer , SeqAccess , Visitor } ,
94
98
ser:: { Serialize , SerializeSeq , Serializer } ,
95
99
} ;
96
- #[ cfg( feature = "write " ) ]
100
+ #[ cfg( feature = "std " ) ]
97
101
use std:: io;
98
102
99
103
/// Error type for APIs with fallible heap allocation
@@ -113,6 +117,10 @@ impl core::fmt::Display for CollectionAllocErr {
113
117
}
114
118
}
115
119
120
+ #[ cfg( feature = "std" ) ]
121
+ #[ cfg_attr( docsrs, doc( cfg( feature = "std" ) ) ) ]
122
+ impl std:: error:: Error for CollectionAllocErr { }
123
+
116
124
/// Either a stack array with `length <= N` or a heap array
117
125
/// whose pointer and capacity are stored here.
118
126
///
@@ -797,7 +805,7 @@ impl<T, const N: usize> SmallVec<T, N> {
797
805
/// the elements `[0, at)` with its previous capacity unchanged.
798
806
///
799
807
/// - If you want to take ownership of the entire contents and capacity of
800
- /// the vector, see [`mem::take`] or [`mem::replace`].
808
+ /// the vector, see [`core:: mem::take`] or [`core:: mem::replace`].
801
809
/// - If you don't need the returned vector at all, see [`SmallVec::truncate`].
802
810
/// - If you want to take ownership of an arbitrary subslice, or you don't
803
811
/// necessarily want to store the removed items in a vector, see [`SmallVec::drain`].
@@ -2145,8 +2153,8 @@ where
2145
2153
}
2146
2154
}
2147
2155
2148
- #[ cfg( feature = "write " ) ]
2149
- #[ cfg_attr( docsrs, doc( cfg( feature = "write " ) ) ) ]
2156
+ #[ cfg( feature = "std " ) ]
2157
+ #[ cfg_attr( docsrs, doc( cfg( feature = "std " ) ) ) ]
2150
2158
impl < const N : usize > io:: Write for SmallVec < u8 , N > {
2151
2159
#[ inline]
2152
2160
fn write ( & mut self , buf : & [ u8 ] ) -> io:: Result < usize > {
0 commit comments