effective/impls/
unwrap.rs1use std::{convert::Infallible, pin::Pin, task::Context};
4
5use crate::{EffectResult, Effective};
6
7pin_project_lite::pin_project!(
8 pub struct Unwrap<E> {
10 #[pin]
11 pub(super) inner: E,
12 }
13);
14
15impl<E> Effective for Unwrap<E>
16where
17 E: Effective,
18 E::Failure: std::fmt::Debug,
19{
20 type Item = E::Item;
21 type Failure = Infallible;
22 type Produces = E::Produces;
23 type Async = E::Async;
24
25 fn poll_effect(
26 self: Pin<&mut Self>,
27 cx: &mut Context<'_>,
28 ) -> EffectResult<Self::Item, Self::Failure, Self::Produces, Self::Async> {
29 let mut this = self.project();
30 match this.inner.as_mut().poll_effect(cx) {
31 EffectResult::Item(x) => EffectResult::Item(x),
32 EffectResult::Failure(x) => panic!("{x:?}"),
33 EffectResult::Done(x) => EffectResult::Done(x),
34 EffectResult::Pending(x) => EffectResult::Pending(x),
35 }
36 }
37
38 fn size_hint(&self) -> (usize, Option<usize>) {
39 self.inner.size_hint()
40 }
41}