1616//!
1717//! ## Optional features
1818//!
19- //! ### `serde `
19+ //! ### `std `
2020//!
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:
2322//!
24- //! ### `write`
23+ //! * `SmallVec<u8, _>` implements the [`std::io::Write`] trait.
24+ //! * [`CollectionAllocErr`] implements [`std::error::Error`].
2525//!
26- //! When this feature is enabled, `SmallVec<u8, _>` implements the `std::io::Write` trait.
2726//! This feature is not compatible with `#![no_std]` programs.
2827//!
28+ //! ### `serde`
29+ //!
30+ //! When this optional dependency is enabled, `SmallVec` implements the `serde::Serialize` and
31+ //! `serde::Deserialize` traits.
32+ //!
2933//! ### `extract_if`
3034//!
3135//! **This feature is unstable.** It may change to match the unstable `extract_if` method in libstd.
6266#[ doc( hidden) ]
6367pub extern crate alloc;
6468
65- #[ cfg( any( test, feature = "write " ) ) ]
69+ #[ cfg( any( test, feature = "std " ) ) ]
6670extern crate std;
6771
6872#[ cfg( test) ]
@@ -93,7 +97,7 @@ use serde::{
9397 de:: { Deserialize , Deserializer , SeqAccess , Visitor } ,
9498 ser:: { Serialize , SerializeSeq , Serializer } ,
9599} ;
96- #[ cfg( feature = "write " ) ]
100+ #[ cfg( feature = "std " ) ]
97101use std:: io;
98102
99103/// Error type for APIs with fallible heap allocation
@@ -113,6 +117,10 @@ impl core::fmt::Display for CollectionAllocErr {
113117 }
114118}
115119
120+ #[ cfg( feature = "std" ) ]
121+ #[ cfg_attr( docsrs, doc( cfg( feature = "std" ) ) ) ]
122+ impl std:: error:: Error for CollectionAllocErr { }
123+
116124/// Either a stack array with `length <= N` or a heap array
117125/// whose pointer and capacity are stored here.
118126///
@@ -797,7 +805,7 @@ impl<T, const N: usize> SmallVec<T, N> {
797805 /// the elements `[0, at)` with its previous capacity unchanged.
798806 ///
799807 /// - 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`].
801809 /// - If you don't need the returned vector at all, see [`SmallVec::truncate`].
802810 /// - If you want to take ownership of an arbitrary subslice, or you don't
803811 /// necessarily want to store the removed items in a vector, see [`SmallVec::drain`].
@@ -2145,8 +2153,8 @@ where
21452153 }
21462154}
21472155
2148- #[ cfg( feature = "write " ) ]
2149- #[ cfg_attr( docsrs, doc( cfg( feature = "write " ) ) ) ]
2156+ #[ cfg( feature = "std " ) ]
2157+ #[ cfg_attr( docsrs, doc( cfg( feature = "std " ) ) ) ]
21502158impl < const N : usize > io:: Write for SmallVec < u8 , N > {
21512159 #[ inline]
21522160 fn write ( & mut self , buf : & [ u8 ] ) -> io:: Result < usize > {
0 commit comments