Skip to content

Commit da5429a

Browse files
authored
Use todo!() instead of unimplemented!() (#1723)
The difference is one of intent, and the actual panic message. See the docs why todo is more appropriate: https://doc.rust-lang.org/stable/std/macro.todo.html [no important files changed] closes #1598
1 parent 5ebc065 commit da5429a

116 files changed

Lines changed: 249 additions & 269 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

concepts/structs/about.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Lastly, methods can be defined on structs inside of an `impl` block:
3232
impl Item {
3333
// initializes and returns a new instance of our Item struct
3434
fn new() -> Self {
35-
unimplemented!()
35+
todo!()
3636
}
3737
}
3838
```
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
pub fn production_rate_per_hour(speed: u8) -> f64 {
2-
unimplemented!("calculate hourly production rate at speed: {speed}")
2+
todo!("calculate hourly production rate at speed: {speed}")
33
}
44

55
pub fn working_items_per_minute(speed: u8) -> u32 {
6-
unimplemented!("calculate the amount of working items at speed: {speed}")
6+
todo!("calculate the amount of working items at speed: {speed}")
77
}

exercises/concept/csv-builder/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@ pub struct CsvRecordBuilder {
99
impl CsvRecordBuilder {
1010
// Create a new builder
1111
pub fn new() -> Self {
12-
unimplemented!("implement the `CsvRecordBuilder::new` method")
12+
todo!("implement the `CsvRecordBuilder::new` method")
1313
}
1414

1515
/// Adds an item to the list separated by a space and a comma.
1616
pub fn add(&mut self, val: &str) {
17-
unimplemented!("implement the `CsvRecordBuilder::add` method, adding {val}")
17+
todo!("implement the `CsvRecordBuilder::add` method, adding {val}")
1818
}
1919

2020
/// Consumes the builder and returns the comma separated list
2121
pub fn build(self) -> String {
22-
unimplemented!("implement the `CsvRecordBuilder::build` method")
22+
todo!("implement the `CsvRecordBuilder::build` method")
2323
}
2424
}

exercises/concept/health-statistics/.docs/introduction.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Lastly, methods can be defined on structs inside of an `impl` block:
3232
impl Item {
3333
// initializes and returns a new instance of our Item struct
3434
fn new() -> Self {
35-
unimplemented!()
35+
todo!()
3636
}
3737
}
3838
```

exercises/concept/health-statistics/src/lib.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,26 @@ pub struct User {
1010

1111
impl User {
1212
pub fn new(name: String, age: u32, weight: f32) -> Self {
13-
unimplemented!()
13+
todo!()
1414
}
1515

1616
pub fn name(&self) -> &str {
17-
unimplemented!()
17+
todo!()
1818
}
1919

2020
pub fn age(&self) -> u32 {
21-
unimplemented!()
21+
todo!()
2222
}
2323

2424
pub fn weight(&self) -> f32 {
25-
unimplemented!()
25+
todo!()
2626
}
2727

2828
pub fn set_age(&mut self, new_age: u32) {
29-
unimplemented!()
29+
todo!()
3030
}
3131

3232
pub fn set_weight(&mut self, new_weight: f32) {
33-
unimplemented!()
33+
todo!()
3434
}
3535
}

exercises/concept/low-power-embedded-game/.docs/hints.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@
1818

1919
## 3. Implement a `manhattan` method on a `Position` tuple struct
2020

21-
- Don't worry about method syntax; just replacing the `unimplemented` portion within the `impl Position` block will do the right thing.
21+
- Don't worry about method syntax; just replacing the `todo` portion within the `impl Position` block will do the right thing.
2222
- Consider that some values within a `Position` may be negative, but a distance is never negative.
2323
- Calculating the absolute value is [built-in](https://doc.rust-lang.org/std/primitive.i16.html#method.abs)

exercises/concept/low-power-embedded-game/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
#![allow(unused)]
44

55
pub fn divmod(dividend: i16, divisor: i16) -> (i16, i16) {
6-
unimplemented!("implement `fn divmod`");
6+
todo!("implement `fn divmod`");
77
}
88

99
pub fn evens<T>(iter: impl Iterator<Item = T>) -> impl Iterator<Item = T> {
10-
unimplemented!("implement `fn evens`");
10+
todo!("implement `fn evens`");
1111
// TODO: remove this; it's only necessary to allow this function to compile
1212
// before the student has done any work.
1313
std::iter::empty()
@@ -16,6 +16,6 @@ pub fn evens<T>(iter: impl Iterator<Item = T>) -> impl Iterator<Item = T> {
1616
pub struct Position(pub i16, pub i16);
1717
impl Position {
1818
pub fn manhattan(&self) -> i16 {
19-
unimplemented!("implement `fn manhattan`")
19+
todo!("implement `fn manhattan`")
2020
}
2121
}
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
pub fn expected_minutes_in_oven() -> i32 {
2-
unimplemented!("return expected minutes in the oven")
2+
todo!("return expected minutes in the oven")
33
}
44

55
pub fn remaining_minutes_in_oven(actual_minutes_in_oven: i32) -> i32 {
6-
unimplemented!(
6+
todo!(
77
"calculate remaining minutes in oven given actual minutes in oven: {actual_minutes_in_oven}"
88
)
99
}
1010

1111
pub fn preparation_time_in_minutes(number_of_layers: i32) -> i32 {
12-
unimplemented!("calculate preparation time in minutes for number of layers: {number_of_layers}")
12+
todo!("calculate preparation time in minutes for number of layers: {number_of_layers}")
1313
}
1414

1515
pub fn elapsed_time_in_minutes(number_of_layers: i32, actual_minutes_in_oven: i32) -> i32 {
16-
unimplemented!(
16+
todo!(
1717
"calculate elapsed time in minutes for number of layers {number_of_layers} and actual minutes in oven {actual_minutes_in_oven}"
1818
)
1919
}

exercises/concept/magazine-cutout/.docs/instructions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ You'll start with the following stubbed function signature:
1313

1414
```rust
1515
pub fn can_construct_note(magazine: &[&str], note: &[&str]) -> bool {
16-
unimplemented!()
16+
todo!()
1717
}
1818
```
1919

exercises/concept/magazine-cutout/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55
use std::collections::HashMap;
66

77
pub fn can_construct_note(magazine: &[&str], note: &[&str]) -> bool {
8-
unimplemented!()
8+
todo!()
99
}

0 commit comments

Comments
 (0)