// Provide a CompletionResult after prefix matching against get_name().
Provide a CompletionResult after prefix matching against get_name().
Provide a CompletionResult after prefix matching against get_name () .
fn complete_by_name<T: HasName>(name: &str, list: &[T]) -> CompletionResult {
    let mut suggestions: Vec<String> = Vec::new();
    for c in list {
        if c.get_name().starts_with(name) {
            suggestions.push(c.get_name().to_string());
        }
    }
    if suggestions.is_empty() {
        CompletionResult::NoMatches
    } else if suggestions.len() == 1 {
        CompletionResult::SingleDiff(suggestions[0][name.len()..].to_string())
    } else {
        CompletionResult::WholeTokenList(suggestions)
    }
}
fn complete_by_name < T : HasName > ( name : & str , list : & [ T ] ) -> CompletionResult { let mut suggestions : Vec < String > = Vec :: new ( ) ; for c in list { if c . get_name ( ) . starts_with ( name ) { suggestions . push ( c . get_name ( ) . to_string ( ) ) ; } } if suggestions . is_empty ( ) { CompletionResult :: NoMatches } else if suggestions . len ( ) == 1 { CompletionResult :: SingleDiff ( suggestions [ 0 ] [ name . len ( ) .. ] . to_string ( ) ) } else { CompletionResult :: WholeTokenList ( suggestions ) } }
Provide a CompletionResult after prefix matching against get_name().
Provide a CompletionResult after prefix matching against get_name () .
name
&str
list
&[T]