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 55
66// I AM NOT DONE
77
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.
1010fn byte_counter < T > ( arg : T ) -> usize {
1111 arg. as_ref ( ) . as_bytes ( ) . len ( )
1212}
1313
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.
1616fn char_counter < T > ( arg : T ) -> usize {
1717 arg. as_ref ( ) . chars ( ) . count ( )
1818}
1919
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 .
2222fn num_sq < T > ( arg : & mut T ) {
23+ // TODO: Implement the function body.
2324 ???
2425}
2526
Original file line number Diff line number Diff line change 66// This function returns how much icecream there is left in the fridge.
77// If it's before 10PM, there's 5 pieces left. At 10PM, someone eats them
88// all, so there'll be no more left :(
9- // TODO: Return an Option!
109fn maybe_icecream ( time_of_day : u16 ) -> Option < u16 > {
1110 // We use the 24-hour system here, so 10PM is a value of 22 and 12AM is a value of 0
1211 // The Option output should gracefully handle cases where time_of_day > 23.
12+ // TODO: Complete the function body - remember to return an Option!
1313 ???
1414}
1515
Original file line number Diff line number Diff line change @@ -42,7 +42,7 @@ mod my_module {
4242
4343#[ cfg( test) ]
4444mod 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?
4646 use ???;
4747 use super :: Command ;
4848
Original file line number Diff line number Diff line change 22// Time to implement some traits!
33//
44// Your task is to implement the trait
5- // `AppendBar' for the type `String' .
5+ // `AppendBar` for the type `String` .
66//
77// The trait AppendBar has only one function,
88// which appends "Bar" to any object
@@ -16,7 +16,7 @@ trait AppendBar {
1616}
1717
1818impl AppendBar for String {
19- //Add your code here
19+ // TODO: Implement `AppendBar` for type `String`.
2020}
2121
2222fn main ( ) {
Original file line number Diff line number Diff line change 11// traits2.rs
22//
33// Your task is to implement the trait
4- // `AppendBar' for a vector of strings.
4+ // `AppendBar` for a vector of strings.
55//
66// To implement this trait, consider for
77// a moment what it means to 'append "Bar"'
@@ -17,7 +17,7 @@ trait AppendBar {
1717 fn append_bar ( self ) -> Self ;
1818}
1919
20- //TODO: Add your code here
20+ // TODO: Implement trait `AppendBar` for a vector of strings.
2121
2222#[ cfg( test) ]
2323mod tests {
Original file line number Diff line number Diff line change @@ -695,7 +695,7 @@ name = "traits2"
695695path = " exercises/traits/traits2.rs"
696696mode = " test"
697697hint = """
698- Notice how the trait takes ownership of 'self',and returns `Self' .
698+ Notice how the trait takes ownership of 'self',and returns `Self` .
699699Try mutating the incoming string vector. Have a look at the tests to see
700700what the result should look like!
701701
You can’t perform that action at this time.
0 commit comments