naan/io/
suspend.rs

1use crate::prelude::*;
2
3/// A deferred computation
4#[derive(Debug, Clone, Copy)]
5#[must_use = "IO is not evaluated until `IOLike.exec` invoked"]
6pub struct Suspend<F>(pub(super) F);
7
8impl<F> Equiv for Suspend<F> where F: F1Once<()>
9{
10  /// `Suspend<F>` is conceptually equivalent to `IO<{return type of F}>`
11  type To = IO<F::Ret>;
12}
13
14impl<F> IOLike<F::Ret> for Suspend<F> where F: F1Once<()>
15{
16  fn exec(self) -> F::Ret {
17    self.0.call1(())
18  }
19}