Skip to content

Commit 4cd31b0

Browse files
authored
Condition Send constraint on from_stream (#2666)
1 parent a57bc38 commit 4cd31b0

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

sdk/core/azure_core/src/http/pager.rs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -217,10 +217,13 @@ impl<P: Page> ItemIterator<P> {
217217
/// Creates a [`ItemIterator<P>`] from a raw stream of [`Result<P>`](typespec::Result<P>) values.
218218
///
219219
/// This constructor is used when you are implementing a completely custom stream and want to use it as a pager.
220-
pub fn from_stream<S>(stream: S) -> Self
221-
where
222-
S: Stream<Item = Result<P, Error>> + Send + 'static,
223-
{
220+
pub fn from_stream<
221+
// This is a bit gnarly, but the only thing that differs between the WASM/non-WASM configs is the presence of Send bounds.
222+
#[cfg(not(target_arch = "wasm32"))] S: Stream<Item = Result<P, Error>> + Send + 'static,
223+
#[cfg(target_arch = "wasm32")] S: Stream<Item = Result<P, Error>> + 'static,
224+
>(
225+
stream: S,
226+
) -> Self {
224227
Self {
225228
stream: Box::pin(stream),
226229
current: None,
@@ -396,10 +399,13 @@ impl<P> PageIterator<P> {
396399
/// Creates a [`PageIterator<P>`] from a raw stream of [`Result<P>`](typespec::Result<P>) values.
397400
///
398401
/// This constructor is used when you are implementing a completely custom stream and want to use it as a pager.
399-
pub fn from_stream<S>(stream: S) -> Self
400-
where
401-
S: Stream<Item = Result<P, Error>> + Send + 'static,
402-
{
402+
pub fn from_stream<
403+
// This is a bit gnarly, but the only thing that differs between the WASM/non-WASM configs is the presence of Send bounds.
404+
#[cfg(not(target_arch = "wasm32"))] S: Stream<Item = Result<P, Error>> + Send + 'static,
405+
#[cfg(target_arch = "wasm32")] S: Stream<Item = Result<P, Error>> + 'static,
406+
>(
407+
stream: S,
408+
) -> Self {
403409
Self {
404410
stream: Box::pin(stream),
405411
}

0 commit comments

Comments
 (0)