MCPcopy Create free account
hub / github.com/GCWing/BitFun / match_substring_in

Function match_substring_in

src/apps/cli/src/commands.rs:137–158  ·  view source on GitHub ↗
(
    query: &str,
    commands: &'static [CommandSpec],
)

Source from the content-addressed store, hash-verified

135];
136
137pub fn match_substring_in(
138 query: &str,
139 commands: &'static [CommandSpec],
140) -> Vec<&'static CommandSpec> {
141 if query.is_empty() {
142 return Vec::new();
143 }
144 let q = query.strip_prefix('/').unwrap_or(query).to_lowercase();
145 if q.is_empty() {
146 return Vec::new();
147 }
148 commands
149 .iter()
150 .filter(|spec| {
151 spec.name
152 .strip_prefix('/')
153 .unwrap_or(spec.name)
154 .to_lowercase()
155 .contains(&q)
156 })
157 .collect()
158}
159
160#[cfg(test)]
161mod tests {

Callers 10

test_exact_matchFunction · 0.85
test_prefix_matchFunction · 0.85
test_substring_matchFunction · 0.85
test_mid_string_matchFunction · 0.85
test_no_matchFunction · 0.85
test_case_insensitiveFunction · 0.85
update_with_commandsMethod · 0.85

Calls 4

collectMethod · 0.80
iterMethod · 0.80
is_emptyMethod · 0.45
containsMethod · 0.45

Tested by 9

test_exact_matchFunction · 0.68
test_prefix_matchFunction · 0.68
test_substring_matchFunction · 0.68
test_mid_string_matchFunction · 0.68
test_no_matchFunction · 0.68
test_case_insensitiveFunction · 0.68