Skip to content

Commit 415534d

Browse files
committed
Fix the lifetime errors by cloning
1 parent 30b1c99 commit 415534d

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ fn main() {
7878
fn process_module_type(
7979
titles: clap::Values,
8080
module_type_str: &str,
81-
options: &'static Options,
81+
options: &Options,
8282
) -> Vec<Module> {
8383
let mut modules_from_type = Vec::new();
8484

src/module.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ pub enum ModuleType {
1414
pub struct Input {
1515
mod_type: ModuleType,
1616
title: String,
17-
options: &'static Options,
17+
options: Options,
1818
includes: Option<Vec<String>>,
1919
}
2020

@@ -38,8 +38,9 @@ const REFERENCE_TEMPLATE: &str = include_str!("../templates/reference.adoc");
3838

3939

4040
impl Input {
41-
pub fn new(mod_type: ModuleType, title: &str, options: &'static Options) -> Input {
41+
pub fn new(mod_type: ModuleType, title: &str, options: &Options) -> Input {
4242
let title = String::from(title);
43+
let options = options.clone();
4344

4445
Input {
4546
mod_type,
@@ -236,7 +237,7 @@ impl From<Input> for Module {
236237

237238
impl Module {
238239
/// The constructor for the Module struct
239-
pub fn new(mod_type: ModuleType, title: &str, options: &'static Options) -> Module {
240+
pub fn new(mod_type: ModuleType, title: &str, options: &Options) -> Module {
240241
let input = Input::new(mod_type, title, options);
241242
input.into()
242243
}

src/write.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ use crate::module::Module;
99

1010
impl Module {
1111
/// Write the generated module content to the path specified in `options` with the set file name.
12-
pub fn write_file(&self) {
12+
pub fn write_file(&self, options: &Options) {
1313
// Compose the full (but still relative) file path from the target directory and the file name
14-
let full_path_buf: PathBuf = [&self.options.target_dir, &self.file_name].iter().collect();
14+
let full_path_buf: PathBuf = [&options.target_dir, &self.file_name].iter().collect();
1515
let full_path = full_path_buf.as_path();
1616

1717
// If the target file already exists, just print out an error

0 commit comments

Comments
 (0)