I AM NOT DONE comment in conversions exercise files
This commit is contained in:
parent
0c85dc1193
commit
fc26b5e151
@ -2,12 +2,14 @@
|
|||||||
// Read more about them at https://doc.rust-lang.org/std/convert/trait.AsRef.html
|
// Read more 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.
|
// and https://doc.rust-lang.org/std/convert/trait.AsMut.html, respectively.
|
||||||
|
|
||||||
|
// 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
|
// 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()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// I AM NOT DONE
|
||||||
// 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
|
// Add the AsRef trait appropriately as a trait bound
|
||||||
fn char_counter<T>(arg: T) -> usize {
|
fn char_counter<T>(arg: T) -> usize {
|
||||||
|
@ -18,6 +18,7 @@ impl Default for Person {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// I AM NOT DONE
|
||||||
// Your task is to complete this implementation
|
// Your task is to complete this implementation
|
||||||
// in order for the line `let p = Person::from("Mark,20")` to compile
|
// in order for the line `let p = Person::from("Mark,20")` to compile
|
||||||
// Please note that you'll need to parse the age component into a `usize`
|
// Please note that you'll need to parse the age component into a `usize`
|
||||||
|
@ -10,6 +10,7 @@ struct Person {
|
|||||||
age: usize,
|
age: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// I AM NOT DONE
|
||||||
// Steps:
|
// Steps:
|
||||||
// 1. If the length of the provided string is 0, then return an error
|
// 1. If the length of the provided string is 0, then return an error
|
||||||
// 2. Split the given string on the commas present in it
|
// 2. Split the given string on the commas present in it
|
||||||
|
@ -10,6 +10,7 @@ struct Person {
|
|||||||
age: usize,
|
age: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// I AM NOT DONE
|
||||||
// Your task is to complete this implementation
|
// Your task is to complete this implementation
|
||||||
// in order for the line `let p = Person::try_from("Mark,20")` to compile
|
// in order for the line `let p = Person::try_from("Mark,20")` to compile
|
||||||
// and return an Ok result of inner type Person.
|
// and return an Ok result of inner type Person.
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
// Please note that the `as` operator is not only used when type casting.
|
// Please note that the `as` operator is not only used when type casting.
|
||||||
// It also helps with renaming imports.
|
// It also helps with renaming imports.
|
||||||
|
|
||||||
|
// I AM NOT DONE
|
||||||
// The goal is to make sure that the division does not fail to compile
|
// The goal is to make sure that the division does not fail to compile
|
||||||
fn average(values: &[f64]) -> f64 {
|
fn average(values: &[f64]) -> f64 {
|
||||||
let total = values
|
let total = values
|
||||||
|
Reference in New Issue
Block a user