diff --git a/kakplugin/src/lib.rs b/kakplugin/src/lib.rs index 4f359ea..431cdea 100644 --- a/kakplugin/src/lib.rs +++ b/kakplugin/src/lib.rs @@ -23,8 +23,11 @@ pub fn get_selections(keys: Option<&'_ str>) -> Result, KakError> /// /// Will return `Err` if command fifo could not be opened, read from, or written to // TODO: Use AsRef -pub fn get_selections_desc(keys: Option<&'_ str>) -> Result, KakError> { - response("%val{selections_desc}", keys)? +pub fn get_selections_desc(keys: Option) -> Result, KakError> +where + S: AsRef, +{ + response("%val{selections_desc}", keys.as_ref())? .iter() .map(|sd| SelectionDesc::from_str(sd)) .collect::, KakError>>() @@ -184,9 +187,10 @@ where /// # Errors /// /// Will return `Err` if command fifo could not be opened or written to -pub fn response(msg: S1, keys: Option<&'_ str>) -> Result, KakError> +pub fn response(msg: S1, keys: Option) -> Result, KakError> where S1: AsRef, + S2: AsRef, { let response_fifo = get_var("kak_response_fifo")?; diff --git a/src/box_.rs b/src/box_.rs index ab066af..bf6a7fb 100644 --- a/src/box_.rs +++ b/src/box_.rs @@ -12,8 +12,10 @@ pub struct Options { pub fn box_(options: &Options) -> Result { if options.bounding_box { // The user requested only the bounding box, so select it first - set_selections_desc(vec![get_bounding_box(get_selections_desc(None)?) - .ok_or_else(|| KakError::Custom(String::from("Selection is empty")))?])?; + set_selections_desc(vec![get_bounding_box(get_selections_desc::<&str>(None)?) + .ok_or_else(|| { + KakError::Custom(String::from("Selection is empty")) + })?])?; } let ret_selections_desc = boxed_selections(options)?; @@ -62,7 +64,7 @@ where fn boxed_selections(_options: &Options) -> Result, KakError> { // The selections we want to box, one per box let selections_desc = { - let mut ret = get_selections_desc(None)?; + let mut ret = get_selections_desc::<&str>(None)?; ret.sort(); ret }; diff --git a/src/main.rs b/src/main.rs index 1ea990f..1d130ac 100644 --- a/src/main.rs +++ b/src/main.rs @@ -48,7 +48,7 @@ enum Commands { Shuf(shuf::Options), #[clap(about = "Find unique selections based on optional regex match")] Uniq(uniq::Options), - #[clap(about = "Invert all selections"), visible_aliases = &["inverse"]] + #[clap(about = "Invert all selections", visible_aliases = &["inverse"])] Invert(invert::Options), #[clap(about = "Evaluate selections as a math expression", visible_aliases = &["bc", "eval"])] MathEval(math_eval::Options), diff --git a/src/uniq.rs b/src/uniq.rs index 8e1ddea..7ec9bf8 100644 --- a/src/uniq.rs +++ b/src/uniq.rs @@ -51,7 +51,7 @@ pub fn uniq(options: &Options) -> Result { }))?; // Deselect all `None` strings (all rows that have been seen before) - let mut new_selections_desc = get_selections_desc(None)?; + let mut new_selections_desc = get_selections_desc::<&str>(None)?; new_selections_desc.sort(); set_selections_desc( // Refresh seelections_desc because positions have changed