partial_context/
lib.rs

1#[cfg(feature = "derive")]
2pub use partial_context_codegen::PartialContext;
3
4pub trait PartialContext<L, R>
5where
6    L: From<R>,
7{
8    fn has_context(&self) -> bool;
9    fn needs_context(&self) -> bool {
10        !self.has_context()
11    }
12
13    /// infallible since L is from R we can always fall back to L
14    fn partial(self) -> L;
15
16    /// can panic if R does not have context
17    fn unwrap_context(self) -> R;
18
19    fn context(self) -> Option<R>;
20}