diff options
author | Nadrieril Feneanar | 2019-11-11 18:30:36 +0100 |
---|---|---|
committer | GitHub | 2019-11-11 18:30:36 +0100 |
commit | bbb089d219cb22751d7100fe6524063cbe2474dd (patch) | |
tree | 4c64231fd014215b962cb294d4672d6785326372 /dhall/src/phase/binary.rs | |
parent | 84cd6f386d6f4c7952fbc1da87dcd754f26ee404 (diff) | |
parent | facd2c587d96510c5a808f19d37b40c1fc2d2618 (diff) |
Merge pull request #115 from Nadrieril/parse-selection-be-expr
Parse projection by expression
Diffstat (limited to '')
-rw-r--r-- | dhall/src/phase/binary.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/dhall/src/phase/binary.rs b/dhall/src/phase/binary.rs index b4f18da..464d71a 100644 --- a/dhall/src/phase/binary.rs +++ b/dhall/src/phase/binary.rs @@ -181,6 +181,15 @@ fn cbor_value_to_dhall(data: &cbor::Value) -> Result<DecodedExpr, DecodeError> { let l = Label::from(l.as_str()); Field(x, l) } + [U64(10), x, Array(arr)] => { + let x = cbor_value_to_dhall(&x)?; + if let [y] = arr.as_slice() { + let y = cbor_value_to_dhall(&y)?; + ProjectionByExpr(x, y) + } else { + Err(DecodeError::WrongFormatError("projection-by-expr".to_owned()))? + } + } [U64(10), x, rest @ ..] => { let x = cbor_value_to_dhall(&x)?; let labels = rest @@ -577,6 +586,7 @@ where .chain(once(expr(x))) .chain(ls.iter().map(label)), ), + ProjectionByExpr(x, y) => ser_seq!(ser; tag(10), expr(x), vec![expr(y)]), Import(import) => serialize_import(ser, import), Embed(_) => unimplemented!( "An expression with resolved imports cannot be binary-encoded" |