get_completion should borrow
This commit is contained in:
parent
85c2933829
commit
3df2c166b1
@ -24,7 +24,7 @@ pub fn generate_hint(input: &str) -> HintEnum<'static> {
|
|||||||
|
|
||||||
for i in (1..=MAX_COMPLETION_LEN).rev().filter(|i| len >= *i) {
|
for i in (1..=MAX_COMPLETION_LEN).rev().filter(|i| len >= *i) {
|
||||||
if let Some(output) = get_completion(&chars_take(&chars, 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"));
|
include!(concat!(env!("OUT_DIR"), "/codegen.rs"));
|
||||||
|
|
||||||
/// Gets completion from `COMPLETION_HASHMAP`
|
/// Gets completion from `COMPLETION_HASHMAP`
|
||||||
pub fn get_completion(key: &str) -> Option<HintEnum<'static>> {
|
pub fn get_completion(key: &str) -> Option<&HintEnum<'static>> {
|
||||||
// If key is empty, just return None
|
// If key is empty, just return None
|
||||||
if key.is_empty() {
|
if key.is_empty() {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get and clone the recieved data
|
// Get and clone the recieved data
|
||||||
COMPLETION_HASHMAP.get(key).cloned()
|
COMPLETION_HASHMAP.get(key)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user