File tree Expand file tree Collapse file tree 6 files changed +14
-13
lines changed Expand file tree Collapse file tree 6 files changed +14
-13
lines changed Original file line number Diff line number Diff line change 5
5
6
6
// I AM NOT DONE
7
7
8
- // Obtain the number of bytes (not characters) in the given argument
9
- // Add the AsRef trait appropriately as a trait bound
8
+ // Obtain the number of bytes (not characters) in the given argument.
9
+ // TODO: Add the AsRef trait appropriately as a trait bound.
10
10
fn byte_counter < T > ( arg : T ) -> usize {
11
11
arg. as_ref ( ) . as_bytes ( ) . len ( )
12
12
}
13
13
14
- // Obtain the number of characters (not bytes) in the given argument
15
- // Add the AsRef trait appropriately as a trait bound
14
+ // Obtain the number of characters (not bytes) in the given argument.
15
+ // TODO: Add the AsRef trait appropriately as a trait bound.
16
16
fn char_counter < T > ( arg : T ) -> usize {
17
17
arg. as_ref ( ) . chars ( ) . count ( )
18
18
}
19
19
20
- // Squares a number using as_mut(). Add the trait bound as is appropriate and
21
- // implement the function body .
20
+ // Squares a number using as_mut().
21
+ // TODO: Add the appropriate trait bound .
22
22
fn num_sq < T > ( arg : & mut T ) {
23
+ // TODO: Implement the function body.
23
24
???
24
25
}
25
26
Original file line number Diff line number Diff line change 6
6
// This function returns how much icecream there is left in the fridge.
7
7
// If it's before 10PM, there's 5 pieces left. At 10PM, someone eats them
8
8
// all, so there'll be no more left :(
9
- // TODO: Return an Option!
10
9
fn maybe_icecream ( time_of_day : u16 ) -> Option < u16 > {
11
10
// We use the 24-hour system here, so 10PM is a value of 22 and 12AM is a value of 0
12
11
// The Option output should gracefully handle cases where time_of_day > 23.
12
+ // TODO: Complete the function body - remember to return an Option!
13
13
???
14
14
}
15
15
Original file line number Diff line number Diff line change @@ -42,7 +42,7 @@ mod my_module {
42
42
43
43
#[ cfg( test) ]
44
44
mod tests {
45
- // TODO: What do we have to import to have `transformer` in scope?
45
+ // TODO: What do we need to import to have `transformer` in scope?
46
46
use ???;
47
47
use super :: Command ;
48
48
Original file line number Diff line number Diff line change 2
2
// Time to implement some traits!
3
3
//
4
4
// Your task is to implement the trait
5
- // `AppendBar' for the type `String' .
5
+ // `AppendBar` for the type `String` .
6
6
//
7
7
// The trait AppendBar has only one function,
8
8
// which appends "Bar" to any object
@@ -16,7 +16,7 @@ trait AppendBar {
16
16
}
17
17
18
18
impl AppendBar for String {
19
- //Add your code here
19
+ // TODO: Implement `AppendBar` for type `String`.
20
20
}
21
21
22
22
fn main ( ) {
Original file line number Diff line number Diff line change 1
1
// traits2.rs
2
2
//
3
3
// Your task is to implement the trait
4
- // `AppendBar' for a vector of strings.
4
+ // `AppendBar` for a vector of strings.
5
5
//
6
6
// To implement this trait, consider for
7
7
// a moment what it means to 'append "Bar"'
@@ -17,7 +17,7 @@ trait AppendBar {
17
17
fn append_bar ( self ) -> Self ;
18
18
}
19
19
20
- //TODO: Add your code here
20
+ // TODO: Implement trait `AppendBar` for a vector of strings.
21
21
22
22
#[ cfg( test) ]
23
23
mod tests {
Original file line number Diff line number Diff line change @@ -695,7 +695,7 @@ name = "traits2"
695
695
path = " exercises/traits/traits2.rs"
696
696
mode = " test"
697
697
hint = """
698
- Notice how the trait takes ownership of 'self',and returns `Self' .
698
+ Notice how the trait takes ownership of 'self',and returns `Self` .
699
699
Try mutating the incoming string vector. Have a look at the tests to see
700
700
what the result should look like!
701
701
You can’t perform that action at this time.
0 commit comments