summaryrefslogtreecommitdiff
path: root/dhall_core/src/core.rs
diff options
context:
space:
mode:
authorNadrieril2019-04-04 18:12:19 +0200
committerNadrieril2019-04-04 18:12:19 +0200
commit04c6cd248aff1cbce68ae2fb997705e921d21809 (patch)
tree94f296ab1a70247e5019e76095ff4b0f0c060c04 /dhall_core/src/core.rs
parent4fe44eea36eaf3cc21ef46740825e9aae4d1ea9e (diff)
Tweak matching on Some/None
Diffstat (limited to '')
-rw-r--r--dhall_core/src/core.rs19
1 files changed, 19 insertions, 0 deletions
diff --git a/dhall_core/src/core.rs b/dhall_core/src/core.rs
index 0ea8c83..afa3d3f 100644
--- a/dhall_core/src/core.rs
+++ b/dhall_core/src/core.rs
@@ -324,6 +324,25 @@ pub fn rc<T>(x: T) -> Rc<T> {
Rc::new(x)
}
+pub fn app<N, E>(f: Expr<N, E>, args: Vec<SubExpr<N, E>>) -> Expr<N, E> {
+ if args.is_empty() {
+ f
+ } else {
+ Expr::App(rc(f), args)
+ }
+}
+
+pub fn app_rc<N, E>(
+ f: SubExpr<N, E>,
+ args: Vec<SubExpr<N, E>>,
+) -> SubExpr<N, E> {
+ if args.is_empty() {
+ f
+ } else {
+ rc(Expr::App(f, args))
+ }
+}
+
fn add_ui(u: usize, i: isize) -> usize {
if i < 0 {
u.checked_sub(i.checked_neg().unwrap() as usize).unwrap()