summaryrefslogtreecommitdiff
path: root/dhall/src/binary.rs
diff options
context:
space:
mode:
Diffstat (limited to 'dhall/src/binary.rs')
-rw-r--r--dhall/src/binary.rs18
1 files changed, 15 insertions, 3 deletions
diff --git a/dhall/src/binary.rs b/dhall/src/binary.rs
index 0f09987..6d0f1e9 100644
--- a/dhall/src/binary.rs
+++ b/dhall/src/binary.rs
@@ -160,9 +160,21 @@ fn cbor_value_to_dhall(data: &cbor::Value) -> Result<ParsedExpr, DecodeError> {
[U64(15), U64(x)] => Ok(NaturalLit(*x as Natural)),
[U64(16), U64(x)] => Ok(IntegerLit(*x as Integer)),
[U64(16), I64(x)] => Ok(IntegerLit(*x as Integer)),
- [U64(18), String(first), _rest..] => {
- // TODO: interpolated string
- Ok(TextLit(first.clone()))
+ [U64(18), String(first), rest..] => {
+ Ok(TextLit(InterpolatedText::from((
+ first.clone(),
+ rest.iter()
+ .tuples()
+ .map(|(x, y)| {
+ let x = cbor_value_to_dhall(&x)?;
+ let y = match y {
+ String(s) => s.clone(),
+ _ => Err(DecodeError::WrongFormatError)?,
+ };
+ Ok((x, y))
+ })
+ .collect::<Result<_, _>>()?,
+ ))))
}
[U64(25), bindings..] => {
let mut tuples = bindings.iter().tuples();