diff options
author | Nadrieril | 2020-02-11 19:04:44 +0000 |
---|---|---|
committer | Nadrieril | 2020-02-11 19:04:44 +0000 |
commit | 40bee3cdcb9ac0c76996feeceb6ca160a6bd8b42 (patch) | |
tree | cf764db516eee081be11587d66569961645a48eb /dhall/src/syntax/binary/encode.rs | |
parent | cab75190e86e8fd4ccc209499c0e7f300a669022 (diff) |
Introduce LitKind to factor out common enum nodes
Diffstat (limited to '')
-rw-r--r-- | dhall/src/syntax/binary/encode.rs | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/dhall/src/syntax/binary/encode.rs b/dhall/src/syntax/binary/encode.rs index 686f737..291ac4a 100644 --- a/dhall/src/syntax/binary/encode.rs +++ b/dhall/src/syntax/binary/encode.rs @@ -46,6 +46,7 @@ where use std::iter::once; use syntax::Builtin; use syntax::ExprKind::*; + use syntax::LitKind::*; use self::Serialize::{RecordMap, UnionMap}; fn expr(x: &Expr) -> self::Serialize<'_> { @@ -60,10 +61,10 @@ where match e.as_ref() { Const(c) => ser.serialize_str(&c.to_string()), Builtin(b) => ser.serialize_str(&b.to_string()), - BoolLit(b) => ser.serialize_bool(*b), - NaturalLit(n) => ser_seq!(ser; tag(15), U64(*n as u64)), - IntegerLit(n) => ser_seq!(ser; tag(16), I64(*n as i64)), - DoubleLit(n) => { + Lit(Bool(b)) => ser.serialize_bool(*b), + Lit(Natural(n)) => ser_seq!(ser; tag(15), U64(*n as u64)), + Lit(Integer(n)) => ser_seq!(ser; tag(16), I64(*n as i64)), + Lit(Double(n)) => { let n: f64 = (*n).into(); ser.serialize_f64(n) } |