File tree Expand file tree Collapse file tree 2 files changed +6
-4
lines changed Expand file tree Collapse file tree 2 files changed +6
-4
lines changed Original file line number Diff line number Diff line change 2
2
// about them at https://doc.rust-lang.org/std/convert/trait.AsRef.html and
3
3
// https://doc.rust-lang.org/std/convert/trait.AsMut.html, respectively.
4
4
5
- // Obtain the number of bytes (not characters) in the given argument.
5
+ // Obtain the number of bytes (not characters) in the given argument
6
+ // (`.len()` returns the number of bytes in a string).
6
7
// TODO: Add the `AsRef` trait appropriately as a trait bound.
7
8
fn byte_counter < T > ( arg : T ) -> usize {
8
- arg. as_ref ( ) . as_bytes ( ) . len ( )
9
+ arg. as_ref ( ) . len ( )
9
10
}
10
11
11
12
// Obtain the number of characters (not bytes) in the given argument.
Original file line number Diff line number Diff line change 2
2
// about them at https://doc.rust-lang.org/std/convert/trait.AsRef.html and
3
3
// https://doc.rust-lang.org/std/convert/trait.AsMut.html, respectively.
4
4
5
- // Obtain the number of bytes (not characters) in the given argument.
5
+ // Obtain the number of bytes (not characters) in the given argument
6
+ // (`.len()` returns the number of bytes in a string).
6
7
fn byte_counter < T : AsRef < str > > ( arg : T ) -> usize {
7
- arg. as_ref ( ) . as_bytes ( ) . len ( )
8
+ arg. as_ref ( ) . len ( )
8
9
}
9
10
10
11
// Obtain the number of characters (not bytes) in the given argument.
You can’t perform that action at this time.
0 commit comments