From e73f822b6972e8fa2e72b56ff5378b91bea1a5e6 Mon Sep 17 00:00:00 2001 From: Fintan Halpenny Date: Mon, 2 Sep 2019 21:17:00 +0100 Subject: Remove the notion of Directory and have File be the vector of components --- dhall/src/phase/binary.rs | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) (limited to 'dhall/src/phase/binary.rs') diff --git a/dhall/src/phase/binary.rs b/dhall/src/phase/binary.rs index 6bdc3f9..89b6db2 100644 --- a/dhall/src/phase/binary.rs +++ b/dhall/src/phase/binary.rs @@ -7,7 +7,7 @@ use dhall_syntax::map::DupTreeMap; use dhall_syntax::{ rc, ExprF, FilePrefix, Hash, Import, ImportHashed, ImportLocation, ImportMode, Integer, InterpolatedText, Label, Natural, Scheme, SubExpr, - URL, V, Directory, File, + URL, V, File, }; use crate::error::{DecodeError, EncodeError}; @@ -291,7 +291,7 @@ fn cbor_value_to_dhall( "import/remote/query".to_owned(), ))?, }; - let mut components: Vec<_> = rest + let file_path: Vec<_> = rest .map(|s| match s.as_string() { Some(s) => Ok(s.clone()), None => Err(DecodeError::WrongFormatError( @@ -299,11 +299,7 @@ fn cbor_value_to_dhall( )), }) .collect::>()?; - let file = components.pop().ok_or( - DecodeError::WrongFormatError( - "import/remote/path".to_owned(), - ))?; - let path = File { directory: Directory { components: components }, file: file }; + let path = File { file_path }; ImportLocation::Remote(URL { scheme, authority, @@ -322,7 +318,7 @@ fn cbor_value_to_dhall( "import/local/prefix".to_owned(), ))?, }; - let mut components: Vec<_> = rest + let file_path: Vec<_> = rest .map(|s| match s.as_string() { Some(s) => Ok(s.clone()), None => Err(DecodeError::WrongFormatError( @@ -330,11 +326,7 @@ fn cbor_value_to_dhall( )), }) .collect::>()?; - let file = components.pop().ok_or( - DecodeError::WrongFormatError( - "import/remote/path".to_owned(), - ))?; - let path = File { directory: Directory { components: components }, file: file }; + let path = File { file_path }; ImportLocation::Local(prefix, path) } 6 => { -- cgit v1.2.3