33//! This module contains a number of functions for working with `Stream`s,
44//! including the `StreamExt` trait which adds methods to `Stream` types.
55
6+ use crate :: future:: Either ;
67use core:: pin:: Pin ;
78use futures_core:: future:: Future ;
89use futures_core:: stream:: { FusedStream , Stream } ;
@@ -13,7 +14,8 @@ use futures_core::task::{Context, Poll};
1314use futures_sink:: Sink ;
1415#[ cfg( feature = "alloc" ) ]
1516use alloc:: boxed:: Box ;
16- use crate :: future:: Either ;
17+ #[ cfg( feature = "alloc" ) ]
18+ use futures_core:: stream:: { BoxStream , LocalBoxStream } ;
1719
1820mod iter;
1921pub use self :: iter:: { iter, Iter } ;
@@ -894,8 +896,21 @@ pub trait StreamExt: Stream {
894896 /// This method is only available when the `std` or `alloc` feature of this
895897 /// library is activated, and it is activated by default.
896898 #[ cfg( feature = "alloc" ) ]
897- fn boxed ( self ) -> Pin < Box < Self > >
898- where Self : Sized
899+ fn boxed < ' a > ( self ) -> BoxStream < ' a , Self :: Item >
900+ where Self : Sized + Send + ' a
901+ {
902+ Box :: pin ( self )
903+ }
904+
905+ /// Wrap the stream in a Box, pinning it.
906+ ///
907+ /// Similar to `boxed`, but without the `Send` requirement.
908+ ///
909+ /// This method is only available when the `std` or `alloc` feature of this
910+ /// library is activated, and it is activated by default.
911+ #[ cfg( feature = "alloc" ) ]
912+ fn boxed_local < ' a > ( self ) -> LocalBoxStream < ' a , Self :: Item >
913+ where Self : Sized + ' a
899914 {
900915 Box :: pin ( self )
901916 }
0 commit comments