8
8
#![ doc( html_root_url = "https://rust-lang-nursery.github.io/futures-api-docs/0.3.0-alpha.13/futures_sink" ) ]
9
9
10
10
#![ feature( futures_api) ]
11
+ #![ cfg_attr( all( feature = "alloc" , not( feature = "std" ) ) , feature( alloc) ) ]
12
+
13
+ #[ cfg( all( feature = "alloc" , not( any( feature = "std" , feature = "nightly" ) ) ) ) ]
14
+ compile_error ! ( "The `alloc` feature without `std` requires the `nightly` feature active to explicitly opt-in to unstable features" ) ;
15
+
16
+ #[ cfg( all( feature = "alloc" , not( feature = "std" ) ) ) ]
17
+ extern crate alloc;
18
+ #[ cfg( feature = "std" ) ]
19
+ extern crate std as alloc;
11
20
12
21
use futures_core:: task:: { Waker , Poll } ;
13
22
use core:: pin:: Pin ;
@@ -155,16 +164,16 @@ impl<'a, S: ?Sized + Sink> Sink for Pin<&'a mut S> {
155
164
#[ cfg( feature = "std" ) ]
156
165
mod channel_impls;
157
166
158
- #[ cfg( feature = "std " ) ]
159
- mod if_std {
167
+ #[ cfg( feature = "alloc " ) ]
168
+ mod if_alloc {
160
169
use super :: * ;
161
170
162
171
/// The error type for `Vec` and `VecDequeue` when used as `Sink`s.
163
172
/// Values of this type can never be created.
164
173
#[ derive( Copy , Clone , Debug ) ]
165
174
pub enum VecSinkError { }
166
175
167
- impl < T > Sink for :: std :: vec:: Vec < T > {
176
+ impl < T > Sink for :: alloc :: vec:: Vec < T > {
168
177
type SinkItem = T ;
169
178
type SinkError = VecSinkError ;
170
179
@@ -187,7 +196,7 @@ mod if_std {
187
196
}
188
197
}
189
198
190
- impl < T > Sink for :: std :: collections:: VecDeque < T > {
199
+ impl < T > Sink for :: alloc :: collections:: VecDeque < T > {
191
200
type SinkItem = T ;
192
201
type SinkError = VecSinkError ;
193
202
@@ -210,7 +219,7 @@ mod if_std {
210
219
}
211
220
}
212
221
213
- impl < S : ?Sized + Sink + Unpin > Sink for :: std :: boxed:: Box < S > {
222
+ impl < S : ?Sized + Sink + Unpin > Sink for :: alloc :: boxed:: Box < S > {
214
223
type SinkItem = S :: SinkItem ;
215
224
type SinkError = S :: SinkError ;
216
225
@@ -232,8 +241,8 @@ mod if_std {
232
241
}
233
242
}
234
243
235
- #[ cfg( feature = "std " ) ]
236
- pub use self :: if_std :: * ;
244
+ #[ cfg( feature = "alloc " ) ]
245
+ pub use self :: if_alloc :: * ;
237
246
238
247
#[ cfg( feature = "either" ) ]
239
248
use either:: Either ;
0 commit comments