diff options
| author | dmitri-mamrukov <37354211+dmitri-mamrukov@users.noreply.github.com> | 2019-12-23 21:37:09 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-12-23 21:37:09 -0500 |
| commit | dfdf8093ebbd4145864995627b812780de52f902 (patch) | |
| tree | 5c068c2b50334558d434860c40c552cc970809b0 /exercises | |
| parent | 3906efcd52a004047b460ed548037093de3f523f (diff) | |
Enable a test and improve per clippy's suggestion.
Diffstat (limited to 'exercises')
| -rw-r--r-- | exercises/conversions/as_ref_mut.rs | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/exercises/conversions/as_ref_mut.rs b/exercises/conversions/as_ref_mut.rs index 8a90703..5e80e50 100644 --- a/exercises/conversions/as_ref_mut.rs +++ b/exercises/conversions/as_ref_mut.rs @@ -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() { @@ -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)); } -}
\ No newline at end of file +} |
