summaryrefslogtreecommitdiff
path: root/exercises
diff options
context:
space:
mode:
authorMo <76752051+mo8it@users.noreply.github.com>2024-09-22 11:40:45 +0200
committerGitHub <noreply@github.com>2024-09-22 11:40:45 +0200
commita55e84835995b87cdcdb7f746ac9d0fb477a5586 (patch)
treed780050d7da39965e86ab996817368a64d757660 /exercises
parent4e4b65711a20ae3d02baa79d8295da2b30ec7dd2 (diff)
parent2653c3c4d448e4c3b0def82597796fa749f6f373 (diff)
Merge pull request #2114 from samueltardieu/push-ptorzrrnmxyp
Do not use `.as_bytes().len()` on strings
Diffstat (limited to 'exercises')
-rw-r--r--exercises/23_conversions/as_ref_mut.rs5
1 files changed, 3 insertions, 2 deletions
diff --git a/exercises/23_conversions/as_ref_mut.rs b/exercises/23_conversions/as_ref_mut.rs
index 54f0cd1..d7892dd 100644
--- a/exercises/23_conversions/as_ref_mut.rs
+++ b/exercises/23_conversions/as_ref_mut.rs
@@ -2,10 +2,11 @@
// about them at https://doc.rust-lang.org/std/convert/trait.AsRef.html and
// https://doc.rust-lang.org/std/convert/trait.AsMut.html, respectively.
-// Obtain the number of bytes (not characters) in the given argument.
+// Obtain the number of bytes (not characters) in the given argument
+// (`.len()` returns the number of bytes in a string).
// TODO: Add the `AsRef` trait appropriately as a trait bound.
fn byte_counter<T>(arg: T) -> usize {
- arg.as_ref().as_bytes().len()
+ arg.as_ref().len()
}
// Obtain the number of characters (not bytes) in the given argument.