|
|
@ -5,21 +5,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
// I AM NOT DONE
|
|
|
|
// I AM NOT DONE
|
|
|
|
|
|
|
|
|
|
|
|
// Obtain the number of bytes (not characters) in the given argument
|
|
|
|
// Obtain the number of bytes (not characters) in the given argument.
|
|
|
|
// Add the AsRef trait appropriately as a trait bound
|
|
|
|
// TODO: Add the AsRef trait appropriately as a trait bound.
|
|
|
|
fn byte_counter<T>(arg: T) -> usize {
|
|
|
|
fn byte_counter<T>(arg: T) -> usize {
|
|
|
|
arg.as_ref().as_bytes().len()
|
|
|
|
arg.as_ref().as_bytes().len()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Obtain the number of characters (not bytes) in the given argument
|
|
|
|
// Obtain the number of characters (not bytes) in the given argument.
|
|
|
|
// Add the AsRef trait appropriately as a trait bound
|
|
|
|
// TODO: Add the AsRef trait appropriately as a trait bound.
|
|
|
|
fn char_counter<T>(arg: T) -> usize {
|
|
|
|
fn char_counter<T>(arg: T) -> usize {
|
|
|
|
arg.as_ref().chars().count()
|
|
|
|
arg.as_ref().chars().count()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Squares a number using as_mut(). Add the trait bound as is appropriate and
|
|
|
|
// Squares a number using as_mut().
|
|
|
|
// implement the function body.
|
|
|
|
// TODO: Add the appropriate trait bound.
|
|
|
|
fn num_sq<T>(arg: &mut T) {
|
|
|
|
fn num_sq<T>(arg: &mut T) {
|
|
|
|
|
|
|
|
// TODO: Implement the function body.
|
|
|
|
???
|
|
|
|
???
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|