File tree Expand file tree Collapse file tree 5 files changed +6
-0
lines changed Expand file tree Collapse file tree 5 files changed +6
-0
lines changed Original file line number Diff line number Diff line change 2
2
// Read more about them at https://doc.rust-lang.org/std/convert/trait.AsRef.html
3
3
// and https://doc.rust-lang.org/std/convert/trait.AsMut.html, respectively.
4
4
5
+ // I AM NOT DONE
5
6
// Obtain the number of bytes (not characters) in the given argument
6
7
// Add the AsRef trait appropriately as a trait bound
7
8
fn byte_counter < T > ( arg : T ) -> usize {
8
9
arg. as_ref ( ) . as_bytes ( ) . len ( )
9
10
}
10
11
12
+ // I AM NOT DONE
11
13
// Obtain the number of characters (not bytes) in the given argument
12
14
// Add the AsRef trait appropriately as a trait bound
13
15
fn char_counter < T > ( arg : T ) -> usize {
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ impl Default for Person {
18
18
}
19
19
}
20
20
21
+ // I AM NOT DONE
21
22
// Your task is to complete this implementation
22
23
// in order for the line `let p = Person::from("Mark,20")` to compile
23
24
// Please note that you'll need to parse the age component into a `usize`
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ struct Person {
10
10
age : usize ,
11
11
}
12
12
13
+ // I AM NOT DONE
13
14
// Steps:
14
15
// 1. If the length of the provided string is 0, then return an error
15
16
// 2. Split the given string on the commas present in it
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ struct Person {
10
10
age : usize ,
11
11
}
12
12
13
+ // I AM NOT DONE
13
14
// Your task is to complete this implementation
14
15
// in order for the line `let p = Person::try_from("Mark,20")` to compile
15
16
// and return an Ok result of inner type Person.
Original file line number Diff line number Diff line change 2
2
// Please note that the `as` operator is not only used when type casting.
3
3
// It also helps with renaming imports.
4
4
5
+ // I AM NOT DONE
5
6
// The goal is to make sure that the division does not fail to compile
6
7
fn average ( values : & [ f64 ] ) -> f64 {
7
8
let total = values
You can’t perform that action at this time.
0 commit comments