1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
use crate::prelude::*;

/// A deferred computation
#[derive(Debug, Clone, Copy)]
#[must_use = "IO is not evaluated until `IOLike.exec` invoked"]
pub struct Suspend<F>(pub(super) F);

impl<F> Equiv for Suspend<F> where F: F1Once<()>
{
  /// `Suspend<F>` is conceptually equivalent to `IO<{return type of F}>`
  type To = IO<F::Ret>;
}

impl<F> IOLike<F::Ret> for Suspend<F> where F: F1Once<()>
{
  fn exec(self) -> F::Ret {
    self.0.call1(())
  }
}