diff options
Diffstat (limited to 'src/lib.rs')
-rw-r--r-- | src/lib.rs | 25 |
1 files changed, 24 insertions, 1 deletions
@@ -1,6 +1,29 @@ | |||
1 | mod ast; | 1 | mod ast; |
2 | mod eval; | 2 | mod eval; |
3 | mod parser; | 3 | pub mod parser; |
4 | mod string; | 4 | mod string; |
5 | 5 | ||
6 | pub use eval::evaluate; | 6 | pub use eval::evaluate; |
7 | |||
8 | trait Wrap<T> { | ||
9 | fn wrap<F, U>(self, f: F) -> U | ||
10 | where | ||
11 | F: Fn(T) -> U, | ||
12 | Self: Sized; | ||
13 | |||
14 | fn wrap_ok<E>(self) -> Result<Self, E> | ||
15 | where | ||
16 | Self: Sized, | ||
17 | { | ||
18 | Ok(self) | ||
19 | } | ||
20 | } | ||
21 | |||
22 | impl<T> Wrap<T> for T { | ||
23 | fn wrap<F, U>(self, f: F) -> U | ||
24 | where | ||
25 | F: Fn(T) -> U, | ||
26 | { | ||
27 | f(self) | ||
28 | } | ||
29 | } | ||