summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--exercises/23_conversions/as_ref_mut.rs5
-rw-r--r--solutions/23_conversions/as_ref_mut.rs5
2 files changed, 6 insertions, 4 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.
diff --git a/solutions/23_conversions/as_ref_mut.rs b/solutions/23_conversions/as_ref_mut.rs
index af62e2d..a5d2d4f 100644
--- a/solutions/23_conversions/as_ref_mut.rs
+++ b/solutions/23_conversions/as_ref_mut.rs
@@ -2,9 +2,10 @@
// 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).
fn byte_counter<T: AsRef<str>>(arg: T) -> usize {
- arg.as_ref().as_bytes().len()
+ arg.as_ref().len()
}
// Obtain the number of characters (not bytes) in the given argument.