|
103 | 103 | #![cfg_attr(not(feature = "std"), no_std)] |
104 | 104 | #![cfg_attr(docsrs, feature(doc_cfg), deny(broken_intra_doc_links))] |
105 | 105 | #[cfg(feature = "std-future")] |
106 | | -use pin_project::pin_project; |
| 106 | +use pin_project_lite::pin_project; |
107 | 107 |
|
108 | 108 | pub(crate) mod stdlib; |
109 | 109 |
|
@@ -242,30 +242,44 @@ pub trait WithSubscriber: Sized { |
242 | 242 | } |
243 | 243 | } |
244 | 244 |
|
| 245 | +#[cfg(feature = "std-future")] |
| 246 | +pin_project! { |
| 247 | + /// A future, stream, sink, or executor that has been instrumented with a `tracing` span. |
| 248 | + #[derive(Debug, Clone)] |
| 249 | + pub struct Instrumented<T> { |
| 250 | + #[pin] |
| 251 | + inner: T, |
| 252 | + span: Span, |
| 253 | + } |
| 254 | +} |
| 255 | + |
245 | 256 | /// A future, stream, sink, or executor that has been instrumented with a `tracing` span. |
246 | | -#[cfg_attr(feature = "std-future", pin_project)] |
| 257 | +#[cfg(not(feature = "std-future"))] |
247 | 258 | #[derive(Debug, Clone)] |
248 | 259 | pub struct Instrumented<T> { |
249 | | - #[cfg(feature = "std-future")] |
250 | | - #[pin] |
251 | | - inner: T, |
252 | | - #[cfg(not(feature = "std-future"))] |
253 | 260 | inner: T, |
254 | 261 | span: Span, |
255 | 262 | } |
256 | 263 |
|
| 264 | +#[cfg(all(feature = "std", feature = "std-future"))] |
| 265 | +pin_project! { |
| 266 | + /// A future, stream, sink, or executor that has been instrumented with a |
| 267 | + /// `tracing` subscriber. |
| 268 | + #[cfg_attr(docsrs, doc(cfg(feature = "std")))] |
| 269 | + #[derive(Clone, Debug)] |
| 270 | + pub struct WithDispatch<T> { |
| 271 | + #[pin] |
| 272 | + inner: T, |
| 273 | + dispatch: Dispatch, |
| 274 | + } |
| 275 | +} |
| 276 | + |
257 | 277 | /// A future, stream, sink, or executor that has been instrumented with a |
258 | 278 | /// `tracing` subscriber. |
259 | | -#[cfg(feature = "std")] |
| 279 | +#[cfg(all(feature = "std", not(feature = "std-future")))] |
260 | 280 | #[cfg_attr(docsrs, doc(cfg(feature = "std")))] |
261 | | -#[cfg_attr(feature = "std-future", pin_project)] |
262 | 281 | #[derive(Clone, Debug)] |
263 | 282 | pub struct WithDispatch<T> { |
264 | | - // cfg_attr doesn't work inside structs, apparently... |
265 | | - #[cfg(feature = "std-future")] |
266 | | - #[pin] |
267 | | - inner: T, |
268 | | - #[cfg(not(feature = "std-future"))] |
269 | 283 | inner: T, |
270 | 284 | dispatch: Dispatch, |
271 | 285 | } |
|
0 commit comments