Use cow for xlookup

This commit is contained in:
Austen Adler 2022-10-02 10:46:51 -04:00
parent d897fdea87
commit 093689c02b

View File

@ -5,6 +5,7 @@ use kakplugin::{
Selection, Selection,
}; };
use std::{ use std::{
borrow::Cow,
collections::{ collections::{
btree_map::Entry::{Occupied, Vacant}, btree_map::Entry::{Occupied, Vacant},
hash_map::DefaultHasher, hash_map::DefaultHasher,
@ -33,9 +34,9 @@ pub fn xlookup(options: &Options) -> Result<String, KakError> {
|| { || {
eprintln!("Key '{key}' not found",); eprintln!("Key '{key}' not found",);
err_count += 1; err_count += 1;
String::from("") Cow::Borrowed("")
}, },
ToString::to_string, |s| Cow::Owned(ToString::to_string(s)),
) )
}))?; }))?;