We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 3906efc + dfdf809 commit 3afa96bCopy full SHA for 3afa96b
exercises/conversions/as_ref_mut.rs
@@ -13,7 +13,7 @@ fn byte_counter<T>(arg: T) -> usize {
13
// Obtain the number of characters (not bytes) in the given argument
14
// Add the AsRef trait appropriately as a trait bound
15
fn char_counter<T>(arg: T) -> usize {
16
- arg.as_ref().chars().collect::<Vec<_>>().len()
+ arg.as_ref().chars().count()
17
}
18
19
fn main() {
@@ -31,8 +31,10 @@ mod tests {
31
let s = "Café au lait";
32
assert_ne!(char_counter(s), byte_counter(s));
33
34
+
35
+ #[test]
36
fn same_counts() {
37
let s = "Cafe au lait";
38
assert_eq!(char_counter(s), byte_counter(s));
39
-}
40
+}
0 commit comments