Skip to content

Commit 4f9aad9

Browse files
authored
Drop find_prefixed_util
1 parent d72d6f7 commit 4f9aad9

File tree

1 file changed

+0
-44
lines changed

1 file changed

+0
-44
lines changed

src/common/validation.rs

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -62,19 +62,6 @@ fn get_canonical_util_name(util_name: &str) -> &str {
6262
}
6363
}
6464

65-
/// Finds a utility with a prefix (e.g., "uu_test" -> "test")
66-
pub fn find_prefixed_util<'a>(
67-
binary_name: &str,
68-
mut util_keys: impl Iterator<Item = &'a str>,
69-
) -> Option<&'a str> {
70-
util_keys.find(|util| {
71-
binary_name.ends_with(*util)
72-
&& binary_name.len() > util.len() // Ensure there's actually a prefix
73-
&& !binary_name[..binary_name.len() - (*util).len()]
74-
.ends_with(char::is_alphanumeric)
75-
})
76-
}
77-
7865
/// Gets the binary path from command line arguments
7966
/// # Panics
8067
/// Panics if the binary path cannot be determined
@@ -123,35 +110,4 @@ mod tests {
123110
assert_eq!(name(Path::new("")), None);
124111
assert_eq!(name(Path::new("/")), None);
125112
}
126-
127-
#[test]
128-
fn test_find_prefixed_util() {
129-
let utils = ["test", "cat", "ls", "cp"];
130-
131-
// Test exact prefixed matches
132-
assert_eq!(
133-
find_prefixed_util("uu_test", utils.iter().copied()),
134-
Some("test")
135-
);
136-
assert_eq!(
137-
find_prefixed_util("my-cat", utils.iter().copied()),
138-
Some("cat")
139-
);
140-
assert_eq!(
141-
find_prefixed_util("prefix_ls", utils.iter().copied()),
142-
Some("ls")
143-
);
144-
145-
// Test non-alphanumeric separator requirement
146-
assert_eq!(find_prefixed_util("prefixcat", utils.iter().copied()), None); // no separator
147-
assert_eq!(find_prefixed_util("testcat", utils.iter().copied()), None); // no separator
148-
149-
// Test no match
150-
assert_eq!(find_prefixed_util("unknown", utils.iter().copied()), None);
151-
assert_eq!(find_prefixed_util("", utils.iter().copied()), None);
152-
153-
// Test exact util name (should not match as prefixed)
154-
assert_eq!(find_prefixed_util("test", utils.iter().copied()), None);
155-
assert_eq!(find_prefixed_util("cat", utils.iter().copied()), None);
156-
}
157113
}

0 commit comments

Comments
 (0)