MCPcopy Create free account
hub / github.com/Effect-TS/effect / matches

Function matches

packages/tools/dprint/src/import_groups.rs:155–167  ·  view source on GitHub ↗

Matches a pattern where `*` stands for any run of characters.

(pattern: &str, text: &str)

Source from the content-addressed store, hash-verified

153
154/// Matches a pattern where `*` stands for any run of characters.
155fn matches(pattern: &str, text: &str) -> bool {
156 let mut parts = pattern.split('*');
157 let Some(mut rest) = text.strip_prefix(parts.next().unwrap_or_default()) else {
158 return false;
159 };
160 let Some(mut part) = parts.next() else { return rest.is_empty() };
161 for next in parts {
162 let Some(index) = rest.find(part) else { return false };
163 rest = &rest[index + part.len()..];
164 part = next;
165 }
166 rest.ends_with(part)
167}

Callers 1

groupMethod · 0.70

Calls 3

nextMethod · 0.65
findMethod · 0.65
splitMethod · 0.45

Tested by

no test coverage detected