From 64045e32caff76844f9b78c8433769b470c0e836 Mon Sep 17 00:00:00 2001 From: Denis Isidoro Date: Thu, 19 Mar 2020 20:50:45 -0300 Subject: [PATCH] Remove need for lifetime on FzfOpts (#293) --- src/flows/core.rs | 6 +++--- src/flows/repo.rs | 2 +- src/fzf.rs | 2 +- src/structures/fzf.rs | 8 ++++---- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/flows/core.rs b/src/flows/core.rs index 1cb3de0..7bb6eb3 100644 --- a/src/flows/core.rs +++ b/src/flows/core.rs @@ -29,7 +29,7 @@ fn gen_core_fzf_opts(variant: Variant, config: &Config) -> FzfOpts { Some(format!("{} preview {{}}", filesystem::exe_string())) }, autoselect: !config.no_autoselect, - overrides: config.fzf_overrides.as_ref(), + overrides: config.fzf_overrides.clone(), suggestion_type: SuggestionType::SnippetSelection, ..Default::default() }; @@ -87,7 +87,7 @@ fn prompt_with_suggestions( let mut opts = FzfOpts { autoselect: !config.no_autoselect, - overrides: config.fzf_overrides_var.as_ref(), + overrides: config.fzf_overrides_var.clone(), prompt: Some(display::variable_prompt(varname)), ..Default::default() }; @@ -96,7 +96,7 @@ fn prompt_with_suggestions( opts.suggestion_type = o.suggestion_type; opts.header_lines = o.header_lines; opts.column = o.column; - opts.delimiter = o.delimiter.as_deref(); + opts.delimiter = o.delimiter.clone(); }; let (output, _) = fzf::call(opts, |stdin| { diff --git a/src/flows/repo.rs b/src/flows/repo.rs index 3ef231f..e1aa13f 100644 --- a/src/flows/repo.rs +++ b/src/flows/repo.rs @@ -73,7 +73,7 @@ pub fn add(uri: String) -> Result<(), Box> { header: Some( "Select the cheatsheets you want to import with then hit ".to_string(), ), - overrides: Some(&overrides), + overrides: Some(overrides), ..Default::default() }; diff --git a/src/fzf.rs b/src/fzf.rs index 83cf95c..70bf2cb 100644 --- a/src/fzf.rs +++ b/src/fzf.rs @@ -132,7 +132,7 @@ where get_column( parse_output_single(text, opts.suggestion_type), opts.column, - opts.delimiter, + opts.delimiter.as_deref(), ), result, ) diff --git a/src/structures/fzf.rs b/src/structures/fzf.rs index 94eea45..c24e143 100644 --- a/src/structures/fzf.rs +++ b/src/structures/fzf.rs @@ -1,20 +1,20 @@ use crate::structures::cheat::SuggestionType; -pub struct Opts<'a> { +pub struct Opts { pub query: Option, pub filter: Option, pub prompt: Option, pub preview: Option, pub autoselect: bool, - pub overrides: Option<&'a String>, // TODO: remove &'a + pub overrides: Option, pub header_lines: u8, pub header: Option, pub suggestion_type: SuggestionType, - pub delimiter: Option<&'a str>, + pub delimiter: Option, pub column: Option, } -impl Default for Opts<'_> { +impl Default for Opts { fn default() -> Self { Self { query: None,