Skip to content

Commit

Permalink
Enable a test and improve per clippy's suggestion.
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitri-mamrukov authored Dec 24, 2019
1 parent 3906efc commit dfdf809
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions exercises/conversions/as_ref_mut.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ fn byte_counter<T>(arg: T) -> usize {
// Obtain the number of characters (not bytes) in the given argument
// Add the AsRef trait appropriately as a trait bound
fn char_counter<T>(arg: T) -> usize {
arg.as_ref().chars().collect::<Vec<_>>().len()
arg.as_ref().chars().count()
}

fn main() {
Expand All @@ -31,8 +31,10 @@ mod tests {
let s = "Café au lait";
assert_ne!(char_counter(s), byte_counter(s));
}

#[test]
fn same_counts() {
let s = "Cafe au lait";
assert_eq!(char_counter(s), byte_counter(s));
}
}
}

0 comments on commit dfdf809

Please sign in to comment.