Compare commits

..

No commits in common. "a55e84835995b87cdcdb7f746ac9d0fb477a5586" and "4e4b65711a20ae3d02baa79d8295da2b30ec7dd2" have entirely different histories.

2 changed files with 4 additions and 6 deletions

View file

@ -2,11 +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
// (`.len()` returns the number of bytes in a string).
// Obtain the number of bytes (not characters) in the given argument.
// TODO: Add the `AsRef` trait appropriately as a trait bound.
fn byte_counter<T>(arg: T) -> usize {
arg.as_ref().len()
arg.as_ref().as_bytes().len()
}
// Obtain the number of characters (not bytes) in the given argument.

View file

@ -2,10 +2,9 @@
// 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
// (`.len()` returns the number of bytes in a string).
// Obtain the number of bytes (not characters) in the given argument.
fn byte_counter<T: AsRef<str>>(arg: T) -> usize {
arg.as_ref().len()
arg.as_ref().as_bytes().len()
}
// Obtain the number of characters (not bytes) in the given argument.