diff options
| -rw-r--r-- | crates/divina/src/cli.rs | 4 | ||||
| -rw-r--r-- | crates/divina/src/lib.rs | 4 | ||||
| -rw-r--r-- | crates/divina_compile/src/lib.rs | 25 |
3 files changed, 13 insertions, 20 deletions
diff --git a/crates/divina/src/cli.rs b/crates/divina/src/cli.rs index e373d60..2d8f58e 100644 --- a/crates/divina/src/cli.rs +++ b/crates/divina/src/cli.rs @@ -69,7 +69,7 @@ pub fn execute(divina: &mut crate::Divina) { ("build", Some(_build_matches)) => { divina .compiler - .find_sources(&divina.expose_config().clone()) + .find_sources(divina.expose_config()) .compile() .link(); } @@ -90,7 +90,7 @@ pub fn execute(divina: &mut crate::Divina) { ("show", _) => { let _ = divina .compiler - .find_sources(&divina.expose_config().clone()) + .find_sources(divina.expose_config()) .print_config(); } _ => unreachable!(), diff --git a/crates/divina/src/lib.rs b/crates/divina/src/lib.rs index 2ce057e..5656e73 100644 --- a/crates/divina/src/lib.rs +++ b/crates/divina/src/lib.rs @@ -32,7 +32,7 @@ mod cli; use divina_compile::Compiler; use divina_config::Config; -#[derive(Default)] +#[derive(Default, Clone)] pub struct Divina { config: Config, compiler: Compiler, @@ -58,7 +58,7 @@ impl Divina { } #[must_use] - pub const fn expose_config(&self) -> &Config { &self.config } + pub fn expose_config(&self) -> Config { self.config.clone() } pub fn configure_compiler(&mut self, compiler: Compiler) { self.compiler = compiler; } } diff --git a/crates/divina_compile/src/lib.rs b/crates/divina_compile/src/lib.rs index 5f142cd..3875915 100644 --- a/crates/divina_compile/src/lib.rs +++ b/crates/divina_compile/src/lib.rs @@ -21,13 +21,13 @@ use std::fs; use divina_config::Arch; -#[derive(Debug)] +#[derive(Debug, Clone)] struct Source { filename: String, path: String, } -#[derive(Debug)] +#[derive(Debug, Clone)] struct Package { name: String, sources: Vec<Source>, @@ -36,7 +36,7 @@ struct Package { visual_studio: Option<String>, } -#[derive(Default, Debug)] +#[derive(Default, Debug, Clone)] pub struct Compiler { sources: Vec<Package>, is_package: bool, @@ -45,25 +45,21 @@ impl Compiler { #[must_use] pub fn new() -> Self { Self::default() } - pub fn find_sources(&mut self, config: &divina_config::Config) -> &Self { + pub fn find_sources(&mut self, config: divina_config::Config) -> &Self { if config.config_type == divina_config::ConfigType::Workspace { - for member in config.members.as_ref().expect( + for member in config.members.expect( "!! could not access 'Config.members' from `workspace`, this *shouldn't* be possible", ) { let mut package = Package { - name: member.name.clone().expect( + name: member.name.expect( "!! could not access `Config.?.name` from `workspace`, this *shouldn't* be possible", ), sources: Vec::new(), arch: member .arch - .clone() .expect("!! could not access 'Config.members.?.arch', this *shouldn't* be possible"), - compiler: member - .compiler - .clone() - .unwrap_or_else(|| "yasm".to_string()), - visual_studio: member.clone().visual_studio, + compiler: member.compiler.unwrap_or_else(|| "yasm".to_string()), + visual_studio: member.visual_studio, }; member @@ -101,22 +97,19 @@ impl Compiler { let mut package = Package { name: config .name - .clone() .expect("!! could not access `Config.name` from `Package`, this *shouldn't* be possible"), sources: Vec::new(), arch: config .arch - .clone() .expect("!! could not access 'Config.arch', this *shouldn't* be possible"), compiler: if config.compiler.is_some() { config .compiler - .clone() .expect("!! could not access 'Config.compiler', this *shouldn't be possible") } else { "yasm".to_string() }, - visual_studio: config.clone().visual_studio, + visual_studio: config.visual_studio, }; config |