+12
-2
lines changedFilter options
+12
-2
lines changed Original file line number Diff line number Diff line change
@@ -21,8 +21,9 @@ pub fn cut(input: &str, sep: u8) -> (&str, &str) {
21
21
}
22
22
}
23
23
24
-
pub(crate) fn to_lowercase(s: Cow<str>) -> Cow<str> {
25
-
if !s.chars().any(|c| c.is_uppercase()) {
24
+
pub(crate) fn to_lowercase<'a>(s: impl Into<Cow<'a, str>>) -> Cow<'a, str> {
25
+
let s = s.into();
26
+
if s.chars().any(|c| c.is_uppercase()) {
26
27
Cow::Owned(s.to_lowercase())
27
28
} else {
28
29
s
@@ -47,4 +48,13 @@ mod tests {
47
48
assert_eq!(rcut(buf, b':'), ("A:B", "C"));
48
49
assert_eq!(rcut(buf, b','), ("", "A:B:C"));
49
50
}
51
+
52
+
#[test]
53
+
fn to_lowercase_simple() {
54
+
assert_eq!(to_lowercase("foo"), "foo");
55
+
assert_eq!(to_lowercase("Foo"), "foo");
56
+
assert_eq!(to_lowercase("FoO"), "foo");
57
+
assert_eq!(to_lowercase("fOo"), "foo");
58
+
assert_eq!(to_lowercase("FOO"), "foo");
59
+
}
50
60
}
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4