fp_library/classes/
once.rs1use crate::{hkt::Kind0L1T, make_type_apply};
2
3pub trait Once: Kind0L1T {
4 type Output<A>;
5
6 fn new<A>() -> ApplyOnce<Self, A>;
7
8 fn get<A>(a: &ApplyOnce<Self, A>) -> Option<&A>;
9
10 fn get_mut<A>(a: &mut ApplyOnce<Self, A>) -> Option<&mut A>;
11
12 fn set<A>(
13 a: &ApplyOnce<Self, A>,
14 value: A,
15 ) -> Result<(), A>;
16
17 fn get_or_init<A, B: FnOnce() -> A>(
18 a: &ApplyOnce<Self, A>,
19 f: B,
20 ) -> &A;
21
22 fn into_inner<A>(a: ApplyOnce<Self, A>) -> Option<A>;
23
24 fn take<A>(a: &mut ApplyOnce<Self, A>) -> Option<A>;
25}
26
27make_type_apply!(ApplyOnce, Once, (), (A), "* -> *");