Skip to content

Commit ff1d949

Browse files
committed
tracing(-futures): add Instrumented::span_and_inner_pin_mut
This is useful for implementing poll-type functions on foreign traits. Closes #2804.
1 parent efc690f commit ff1d949

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

tracing-futures/src/lib.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,14 @@ where
449449
}
450450

451451
impl<T> Instrumented<T> {
452+
/// Get both a mutable reference to the `Span` that this type is
453+
/// instrumented by and a pinned mutable reference to the inner value.
454+
///
455+
/// This is useful for implementing poll-type functions on foreign traits.
456+
pub fn span_and_inner_pin_mut(self: Pin<&mut Self>) -> (&mut Span, Pin<&mut T>) {
457+
self.project().span_and_inner_pin_mut()
458+
}
459+
452460
/// Borrows the `Span` that this type is instrumented by.
453461
pub fn span(&self) -> &Span {
454462
&self.span

tracing/src/instrument.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,14 @@ impl<T: Future> Future for Instrumented<T> {
325325
impl<T: Sized> Instrument for T {}
326326

327327
impl<T> Instrumented<T> {
328+
/// Get both a mutable reference to the `Span` that this type is
329+
/// instrumented by and a pinned mutable reference to the inner value.
330+
///
331+
/// This is useful for implementing poll-type functions on foreign traits.
332+
pub fn span_and_inner_pin_mut(self: Pin<&mut Self>) -> (&mut Span, Pin<&mut T>) {
333+
self.project().span_and_inner_pin_mut()
334+
}
335+
328336
/// Borrows the `Span` that this type is instrumented by.
329337
pub fn span(&self) -> &Span {
330338
&self.span

0 commit comments

Comments
 (0)