From f9408f4e030478d440814f16c2a37f091176e9e2 Mon Sep 17 00:00:00 2001 From: Troy Benson Date: Tue, 2 Jul 2024 19:50:59 +0000 Subject: [PATCH] fix: impl context ext for `IntoFuture` rather than `Future` --- foundations/src/context.rs | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/foundations/src/context.rs b/foundations/src/context.rs index d9e19ba6d..2135a095c 100644 --- a/foundations/src/context.rs +++ b/foundations/src/context.rs @@ -1,4 +1,4 @@ -use std::future::Future; +use std::future::{Future, IntoFuture}; use std::pin::Pin; use std::sync::atomic::{AtomicBool, AtomicUsize}; use std::sync::Arc; @@ -227,29 +227,32 @@ impl<'a> From<&'a Context> for ContextRef<'a> { } } -pub trait ContextFutExt { - fn with_context<'a>(self, ctx: impl Into>) -> FutureWithContext<'a, Self> +pub trait ContextFutExt { + fn with_context<'a>(self, ctx: impl Into>) -> FutureWithContext<'a, Fut> where Self: Sized; } -impl ContextFutExt for F { - fn with_context<'a>(self, ctx: impl Into>) -> FutureWithContext<'a, Self> { +impl ContextFutExt for F { + fn with_context<'a>(self, ctx: impl Into>) -> FutureWithContext<'a, F::IntoFuture> + where + F: IntoFuture, + { FutureWithContext { - future: self, + future: self.into_future(), ctx: ctx.into(), } } } -pub trait ContextStreamExt { - fn with_context<'a>(self, ctx: impl Into>) -> StreamWithContext<'a, Self> +pub trait ContextStreamExt { + fn with_context<'a>(self, ctx: impl Into>) -> StreamWithContext<'a, Stream> where Self: Sized; } -impl ContextStreamExt for F { - fn with_context<'a>(self, ctx: impl Into>) -> StreamWithContext<'a, Self> { +impl ContextStreamExt for F { + fn with_context<'a>(self, ctx: impl Into>) -> StreamWithContext<'a, F> { StreamWithContext { stream: self, ctx: ctx.into(),