Remove need for lifetime on FzfOpts (#293)

This commit is contained in:
Denis Isidoro 2020-03-19 20:50:45 -03:00 committed by GitHub
parent 73cd346c1b
commit 64045e32ca
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 9 deletions

View file

@ -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| {

View file

@ -73,7 +73,7 @@ pub fn add(uri: String) -> Result<(), Box<dyn Error>> {
header: Some(
"Select the cheatsheets you want to import with <TAB> then hit <Enter>".to_string(),
),
overrides: Some(&overrides),
overrides: Some(overrides),
..Default::default()
};

View file

@ -132,7 +132,7 @@ where
get_column(
parse_output_single(text, opts.suggestion_type),
opts.column,
opts.delimiter,
opts.delimiter.as_deref(),
),
result,
)

View file

@ -1,20 +1,20 @@
use crate::structures::cheat::SuggestionType;
pub struct Opts<'a> {
pub struct Opts {
pub query: Option<String>,
pub filter: Option<String>,
pub prompt: Option<String>,
pub preview: Option<String>,
pub autoselect: bool,
pub overrides: Option<&'a String>, // TODO: remove &'a
pub overrides: Option<String>,
pub header_lines: u8,
pub header: Option<String>,
pub suggestion_type: SuggestionType,
pub delimiter: Option<&'a str>,
pub delimiter: Option<String>,
pub column: Option<u8>,
}
impl Default for Opts<'_> {
impl Default for Opts {
fn default() -> Self {
Self {
query: None,