From f1f564dfcd328a1b36e6fefb37e023afebc9d68f Mon Sep 17 00:00:00 2001 From: Akshay Date: Sun, 12 Apr 2020 12:11:02 +0530 Subject: all loading paths at runtime --- fondant_derive/src/lib.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'fondant_derive') diff --git a/fondant_derive/src/lib.rs b/fondant_derive/src/lib.rs index a06df15..2f852dc 100644 --- a/fondant_derive/src/lib.rs +++ b/fondant_derive/src/lib.rs @@ -127,8 +127,8 @@ fn gen_impl(ast: &DeriveInput, cfg_path: ConfigPath) -> TokenStream { Self::load_file(&config_file) } - fn load_file(conf_file: &PathBuf) -> Result<#struct_ident, FondantError> { - #load_paths + fn load_file>(conf_file: P) -> Result<#struct_ident, FondantError> { + #load_paths match File::open(&conf_file) { // Note: conf_file is different than config_file from #load_paths Ok(mut cfg) => { let mut cfg_data = String::new(); @@ -149,13 +149,14 @@ fn gen_impl(ast: &DeriveInput, cfg_path: ConfigPath) -> TokenStream { Err(e) => return Err(FondantError::LoadError), }; } + fn store(&self) -> Result<(), FondantError> { #load_paths &self.store_file(&config_file)?; Ok(()) } - fn store_file(&self, conf_file: &PathBuf) -> Result<(), FondantError> { + fn store_file>(&self, conf_file: P) -> Result<(), FondantError> { #load_paths let mut f = OpenOptions::new() .write(true) -- cgit v1.2.3