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 22// about them at https://doc.rust-lang.org/std/convert/trait.AsRef.html and
33// https://doc.rust-lang.org/std/convert/trait.AsMut.html, respectively.
44
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).
67// TODO: Add the `AsRef` trait appropriately as a trait bound.
78fn byte_counter < T > ( arg : T ) -> usize {
8- arg. as_ref ( ) . as_bytes ( ) . len ( )
9+ arg. as_ref ( ) . len ( )
910}
1011
1112// Obtain the number of characters (not bytes) in the given argument.
Original file line number Diff line number Diff line change 22// about them at https://doc.rust-lang.org/std/convert/trait.AsRef.html and
33// https://doc.rust-lang.org/std/convert/trait.AsMut.html, respectively.
44
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).
67fn byte_counter < T : AsRef < str > > ( arg : T ) -> usize {
7- arg. as_ref ( ) . as_bytes ( ) . len ( )
8+ arg. as_ref ( ) . len ( )
89}
910
1011// Obtain the number of characters (not bytes) in the given argument.
You can’t perform that action at this time.
0 commit comments