From 3df2c166b1e1a86cff7e1c303930f09d1a7bc951 Mon Sep 17 00:00:00 2001 From: Simon Gardling Date: Thu, 7 Apr 2022 10:19:59 -0400 Subject: [PATCH] get_completion should borrow --- src/suggestions.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/suggestions.rs b/src/suggestions.rs index 931bafb..34564db 100644 --- a/src/suggestions.rs +++ b/src/suggestions.rs @@ -24,7 +24,7 @@ pub fn generate_hint(input: &str) -> HintEnum<'static> { for i in (1..=MAX_COMPLETION_LEN).rev().filter(|i| len >= *i) { if let Some(output) = get_completion(&chars_take(&chars, i)) { - return output; + return output.clone(); } } @@ -67,14 +67,14 @@ impl HintEnum<'static> { include!(concat!(env!("OUT_DIR"), "/codegen.rs")); /// Gets completion from `COMPLETION_HASHMAP` -pub fn get_completion(key: &str) -> Option> { +pub fn get_completion(key: &str) -> Option<&HintEnum<'static>> { // If key is empty, just return None if key.is_empty() { return None; } // Get and clone the recieved data - COMPLETION_HASHMAP.get(key).cloned() + COMPLETION_HASHMAP.get(key) } #[cfg(test)]