Skip to content

Commit 3afa96b

Browse files
author
fmoko
authored
Enable a test and improve per clippy's suggestion. (#256)
Enable a test and improve per clippy's suggestion.
2 parents 3906efc + dfdf809 commit 3afa96b

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

exercises/conversions/as_ref_mut.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ fn byte_counter<T>(arg: T) -> usize {
1313
// Obtain the number of characters (not bytes) in the given argument
1414
// Add the AsRef trait appropriately as a trait bound
1515
fn char_counter<T>(arg: T) -> usize {
16-
arg.as_ref().chars().collect::<Vec<_>>().len()
16+
arg.as_ref().chars().count()
1717
}
1818

1919
fn main() {
@@ -31,8 +31,10 @@ mod tests {
3131
let s = "Café au lait";
3232
assert_ne!(char_counter(s), byte_counter(s));
3333
}
34+
35+
#[test]
3436
fn same_counts() {
3537
let s = "Cafe au lait";
3638
assert_eq!(char_counter(s), byte_counter(s));
3739
}
38-
}
40+
}

0 commit comments

Comments
 (0)