diff --git a/src/core/utils/string.rs b/src/core/utils/string.rs index 0873b2d5..e4e894e0 100644 --- a/src/core/utils/string.rs +++ b/src/core/utils/string.rs @@ -93,15 +93,19 @@ where /// ``` #[must_use] #[allow(clippy::string_slice)] -pub fn common_prefix<'a>(choice: &'a [&str]) -> &'a str { +pub fn common_prefix>(choice: &[T]) -> &str { choice.first().map_or(EMPTY, move |best| { - choice.iter().skip(1).fold(*best, |best, choice| { - &best[0..choice - .char_indices() - .zip(best.char_indices()) - .take_while(|&(a, b)| a == b) - .count()] - }) + choice + .iter() + .skip(1) + .fold(best.as_ref(), |best, choice| { + &best[0..choice + .as_ref() + .char_indices() + .zip(best.char_indices()) + .take_while(|&(a, b)| a == b) + .count()] + }) }) } diff --git a/src/core/utils/string/tests.rs b/src/core/utils/string/tests.rs index e8c17de6..6eadcf5b 100644 --- a/src/core/utils/string/tests.rs +++ b/src/core/utils/string/tests.rs @@ -16,7 +16,7 @@ fn common_prefix_empty() { #[test] fn common_prefix_none() { - let input = []; + let input: [&str; 0] = []; let output = super::common_prefix(&input); assert_eq!(output, ""); }