From 3cfbe6564c654b3639fd74422077c5f065525d87 Mon Sep 17 00:00:00 2001 From: Jeremy Wall Date: Tue, 19 Feb 2019 15:32:04 -0600 Subject: [PATCH] FEATURE: Empty files result in Val::Empty as their result. We also print a warning message for the consumer. --- src/build/mod.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/build/mod.rs b/src/build/mod.rs index 0864e7c..ab6e05e 100644 --- a/src/build/mod.rs +++ b/src/build/mod.rs @@ -1648,7 +1648,12 @@ impl<'a> FileBuilder<'a> { Some(importer) => { let file_contents = self.get_file_as_string(&def.path.pos, &def.path.fragment)?; - let val = importer.import(file_contents.as_bytes())?; + let val = if file_contents.len() == 0 { + eprintln!("including an empty file. Use NULL as the result"); + Rc::new(Val::Empty) + } else { + importer.import(file_contents.as_bytes())? + }; Ok(val) } None => Err(Box::new(error::BuildError::new(