diff --git a/src/shell/binary.rs b/src/shell/binary.rs index f0a55dd744a61547b25db44381f783c9f430294c..4a8e12e472d7fd1516c8566604f11c7154450995 100644 --- a/src/shell/binary.rs +++ b/src/shell/binary.rs @@ -161,7 +161,7 @@ impl<'a> Binary for Shell<'a> { // Add the list of available variables to the completer's definitions. // TODO: We should make it free to do String->SmallString // and mostly free to go back (free if allocated) - .chain(vars.get_vars().into_iter().map(|s| ["$", &s].concat().into())) + .chain(vars.get_vars().map(|s| ["$", &s].concat().into())) .collect(); // Initialize a new completer from the definitions collected. @@ -441,11 +441,11 @@ fn complete_as_file(current_dir: PathBuf, filename: String, index: usize) -> boo let mut file = current_dir.clone(); file.push(&filename); // If the user explicitly requests a file through this syntax then complete as a file - if filename.trim().starts_with(".") { + if filename.starts_with(".") { return true; } // If the file starts with a dollar sign, it's a variable, not a file - if filename.trim().starts_with("$") { + if filename.starts_with("$") { return false; } // Once we are beyond the first string, assume its a file diff --git a/src/shell/variables/mod.rs b/src/shell/variables/mod.rs index fad2012c229eb4b1ea3eda229c4e6872149574b5..5cd382db1a343adb5bfe9bcc7463560592af69df 100644 --- a/src/shell/variables/mod.rs +++ b/src/shell/variables/mod.rs @@ -257,8 +257,8 @@ impl Variables { pub fn unset_var(&mut self, name: &str) -> Option<Value> { self.variables.remove(name) } - pub fn get_vars(&self) -> Vec<Identifier> { - self.variables.keys().cloned().chain(env::vars().map(|(k, _)| k.into())).collect() + pub fn get_vars<'a>(&'a self) -> impl Iterator<Item = Identifier> + 'a { + self.variables.keys().cloned().chain(env::vars().map(|(k, _)| k.into())) } pub(crate) fn is_valid_variable_character(c: char) -> bool {