Skip to content

Commit

Permalink
Use todo!() instead of unimplemented!()
Browse files Browse the repository at this point in the history
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
  • Loading branch information
senekor committed Sep 10, 2023
1 parent 8cacd6b commit 7949362
Show file tree
Hide file tree
Showing 116 changed files with 249 additions and 269 deletions.
2 changes: 1 addition & 1 deletion concepts/structs/about.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Lastly, methods can be defined on structs inside of an `impl` block:
impl Item {
// initializes and returns a new instance of our Item struct
fn new() -> Self {
unimplemented!()
todo!()
}
}
```
Expand Down
4 changes: 2 additions & 2 deletions exercises/concept/assembly-line/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pub fn production_rate_per_hour(speed: u8) -> f64 {
unimplemented!("calculate hourly production rate at speed: {speed}")
todo!("calculate hourly production rate at speed: {speed}")
}

pub fn working_items_per_minute(speed: u8) -> u32 {
unimplemented!("calculate the amount of working items at speed: {speed}")
todo!("calculate the amount of working items at speed: {speed}")
}
6 changes: 3 additions & 3 deletions exercises/concept/csv-builder/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ pub struct CsvRecordBuilder {
impl CsvRecordBuilder {
// Create a new builder
pub fn new() -> Self {
unimplemented!("implement the `CsvRecordBuilder::new` method")
todo!("implement the `CsvRecordBuilder::new` method")
}

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

/// Consumes the builder and returns the comma separated list
pub fn build(self) -> String {
unimplemented!("implement the `CsvRecordBuilder::build` method")
todo!("implement the `CsvRecordBuilder::build` method")
}
}
2 changes: 1 addition & 1 deletion exercises/concept/health-statistics/.docs/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Lastly, methods can be defined on structs inside of an `impl` block:
impl Item {
// initializes and returns a new instance of our Item struct
fn new() -> Self {
unimplemented!()
todo!()
}
}
```
Expand Down
12 changes: 6 additions & 6 deletions exercises/concept/health-statistics/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,26 @@ pub struct User {

impl User {
pub fn new(name: String, age: u32, weight: f32) -> Self {
unimplemented!()
todo!()
}

pub fn name(&self) -> &str {
unimplemented!()
todo!()
}

pub fn age(&self) -> u32 {
unimplemented!()
todo!()
}

pub fn weight(&self) -> f32 {
unimplemented!()
todo!()
}

pub fn set_age(&mut self, new_age: u32) {
unimplemented!()
todo!()
}

pub fn set_weight(&mut self, new_weight: f32) {
unimplemented!()
todo!()
}
}
2 changes: 1 addition & 1 deletion exercises/concept/low-power-embedded-game/.docs/hints.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@

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

- Don't worry about method syntax; just replacing the `unimplemented` portion within the `impl Position` block will do the right thing.
- Don't worry about method syntax; just replacing the `todo` portion within the `impl Position` block will do the right thing.
- Consider that some values within a `Position` may be negative, but a distance is never negative.
- Calculating the absolute value is [built-in](https://doc.rust-lang.org/std/primitive.i16.html#method.abs)
6 changes: 3 additions & 3 deletions exercises/concept/low-power-embedded-game/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
#![allow(unused)]

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

pub fn evens<T>(iter: impl Iterator<Item = T>) -> impl Iterator<Item = T> {
unimplemented!("implement `fn evens`");
todo!("implement `fn evens`");
// TODO: remove this; it's only necessary to allow this function to compile
// before the student has done any work.
std::iter::empty()
Expand All @@ -16,6 +16,6 @@ pub fn evens<T>(iter: impl Iterator<Item = T>) -> impl Iterator<Item = T> {
pub struct Position(pub i16, pub i16);
impl Position {
pub fn manhattan(&self) -> i16 {
unimplemented!("implement `fn manhattan`")
todo!("implement `fn manhattan`")
}
}
8 changes: 4 additions & 4 deletions exercises/concept/lucians-luscious-lasagna/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
pub fn expected_minutes_in_oven() -> i32 {
unimplemented!("return expected minutes in the oven")
todo!("return expected minutes in the oven")
}

pub fn remaining_minutes_in_oven(actual_minutes_in_oven: i32) -> i32 {
unimplemented!(
todo!(
"calculate remaining minutes in oven given actual minutes in oven: {actual_minutes_in_oven}"
)
}

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

pub fn elapsed_time_in_minutes(number_of_layers: i32, actual_minutes_in_oven: i32) -> i32 {
unimplemented!(
todo!(
"calculate elapsed time in minutes for number of layers {number_of_layers} and actual minutes in oven {actual_minutes_in_oven}"
)
}
2 changes: 1 addition & 1 deletion exercises/concept/magazine-cutout/.docs/instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ You'll start with the following stubbed function signature:

```rust
pub fn can_construct_note(magazine: &[&str], note: &[&str]) -> bool {
unimplemented!()
todo!()
}
```

Expand Down
2 changes: 1 addition & 1 deletion exercises/concept/magazine-cutout/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
use std::collections::HashMap;

pub fn can_construct_note(magazine: &[&str], note: &[&str]) -> bool {
unimplemented!()
todo!()
}
6 changes: 3 additions & 3 deletions exercises/concept/resistor-color/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ pub enum ResistorColor {
}

pub fn color_to_value(color: ResistorColor) -> u32 {
unimplemented!("convert color {color:?} into a numerical representation")
todo!("convert color {color:?} into a numerical representation")
}

pub fn value_to_color_string(value: u32) -> String {
unimplemented!("convert the value {value} into a string representation of color")
todo!("convert the value {value} into a string representation of color")
}

pub fn colors() -> Vec<ResistorColor> {
unimplemented!("return a list of all the colors ordered by resistance")
todo!("return a list of all the colors ordered by resistance")
}
4 changes: 2 additions & 2 deletions exercises/concept/role-playing-game/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ pub struct Player {

impl Player {
pub fn revive(&self) -> Option<Player> {
unimplemented!("Revive this player")
todo!("Revive this player")
}

pub fn cast_spell(&mut self, mana_cost: u32) -> u32 {
unimplemented!("Cast a spell of cost {mana_cost}")
todo!("Cast a spell of cost {mana_cost}")
}
}
2 changes: 1 addition & 1 deletion exercises/concept/rpn-calculator/.docs/instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ pub enum CalculatorInput {
}

pub fn evaluate(inputs: &[CalculatorInput]) -> Option<i32> {
unimplemented!(
todo!(
"Given the inputs: {inputs:?}, evaluate them as though they were a Reverse Polish notation expression"
);
}
Expand Down
2 changes: 1 addition & 1 deletion exercises/concept/rpn-calculator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pub enum CalculatorInput {
}

pub fn evaluate(inputs: &[CalculatorInput]) -> Option<i32> {
unimplemented!(
todo!(
"Given the inputs: {inputs:?}, evaluate them as though they were a Reverse Polish notation expression"
);
}
8 changes: 4 additions & 4 deletions exercises/concept/semi-structured-logs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ pub enum LogLevel {
}
/// primary function for emitting logs
pub fn log(level: LogLevel, message: &str) -> String {
unimplemented!("return a message for the given log level")
todo!("return a message for the given log level")
}
pub fn info(message: &str) -> String {
unimplemented!("return a message for info log level")
todo!("return a message for info log level")
}
pub fn warn(message: &str) -> String {
unimplemented!("return a message for warn log level")
todo!("return a message for warn log level")
}
pub fn error(message: &str) -> String {
unimplemented!("return a message for error log level")
todo!("return a message for error log level")
}
6 changes: 3 additions & 3 deletions exercises/concept/short-fibonacci/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
/// Create an empty vector
pub fn create_empty() -> Vec<u8> {
unimplemented!()
todo!()
}

/// Create a buffer of `count` zeroes.
///
/// Applications often use buffers when serializing data to send over the network.
pub fn create_buffer(count: usize) -> Vec<u8> {
unimplemented!("create a zeroized buffer of {count} bytes")
todo!("create a zeroized buffer of {count} bytes")
}

/// Create a vector containing the first five elements of the Fibonacci sequence.
///
/// Fibonacci's sequence is the list of numbers where the next number is a sum of the previous two.
/// Its first five elements are `1, 1, 2, 3, 5`.
pub fn fibonacci() -> Vec<u8> {
unimplemented!()
todo!()
}
2 changes: 1 addition & 1 deletion exercises/practice/accumulate/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/// What should the type of _function be?
pub fn map(input: Vec<i32>, _function: ???) -> Vec<i32> {
unimplemented!("Transform input vector {input:?} using passed function");
todo!("Transform input vector {input:?} using passed function");
}
2 changes: 1 addition & 1 deletion exercises/practice/acronym/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
pub fn abbreviate(phrase: &str) -> String {
unimplemented!("Given the phrase '{phrase}', return its acronym");
todo!("Given the phrase '{phrase}', return its acronym");
}
4 changes: 2 additions & 2 deletions exercises/practice/affine-cipher/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ pub enum AffineCipherError {
/// Encodes the plaintext using the affine cipher with key (`a`, `b`). Note that, rather than
/// returning a return code, the more common convention in Rust is to return a `Result`.
pub fn encode(plaintext: &str, a: i32, b: i32) -> Result<String, AffineCipherError> {
unimplemented!("Encode {plaintext} with the key ({a}, {b})");
todo!("Encode {plaintext} with the key ({a}, {b})");
}

/// Decodes the ciphertext using the affine cipher with key (`a`, `b`). Note that, rather than
/// returning a return code, the more common convention in Rust is to return a `Result`.
pub fn decode(ciphertext: &str, a: i32, b: i32) -> Result<String, AffineCipherError> {
unimplemented!("Decode {ciphertext} with the key ({a}, {b})");
todo!("Decode {ciphertext} with the key ({a}, {b})");
}
2 changes: 1 addition & 1 deletion exercises/practice/all-your-base/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@ pub enum Error {
/// However, your function must be able to process input with leading 0 digits.
///
pub fn convert(number: &[u32], from_base: u32, to_base: u32) -> Result<Vec<u32>, Error> {
unimplemented!("Convert {number:?} from base {from_base} to base {to_base}")
todo!("Convert {number:?} from base {from_base} to base {to_base}")
}
6 changes: 3 additions & 3 deletions exercises/practice/allergies/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ pub enum Allergen {

impl Allergies {
pub fn new(score: u32) -> Self {
unimplemented!("Given the '{score}' score, construct a new Allergies struct.");
todo!("Given the '{score}' score, construct a new Allergies struct.");
}

pub fn is_allergic_to(&self, allergen: &Allergen) -> bool {
unimplemented!("Determine if the patient is allergic to the '{allergen:?}' allergen.");
todo!("Determine if the patient is allergic to the '{allergen:?}' allergen.");
}

pub fn allergies(&self) -> Vec<Allergen> {
unimplemented!("Return the list of allergens contained within the score with which the Allergies struct was made.");
todo!("Return the list of allergens contained within the score with which the Allergies struct was made.");
}
}
2 changes: 1 addition & 1 deletion exercises/practice/alphametics/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use std::collections::HashMap;

pub fn solve(input: &str) -> Option<HashMap<char, u8>> {
unimplemented!("Solve the alphametic {input:?}")
todo!("Solve the alphametic {input:?}")
}
4 changes: 1 addition & 3 deletions exercises/practice/anagram/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
use std::collections::HashSet;

pub fn anagrams_for<'a>(word: &str, possible_anagrams: &[&str]) -> HashSet<&'a str> {
unimplemented!(
"For the '{word}' word find anagrams among the following words: {possible_anagrams:?}"
);
todo!("For the '{word}' word find anagrams among the following words: {possible_anagrams:?}");
}
2 changes: 1 addition & 1 deletion exercises/practice/armstrong-numbers/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
pub fn is_armstrong_number(num: u32) -> bool {
unimplemented!("true if {num} is an armstrong number")
todo!("true if {num} is an armstrong number")
}
4 changes: 2 additions & 2 deletions exercises/practice/atbash-cipher/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/// "Encipher" with the Atbash cipher.
pub fn encode(plain: &str) -> String {
unimplemented!("Encoding of {plain:?} in Atbash cipher.");
todo!("Encoding of {plain:?} in Atbash cipher.");
}

/// "Decipher" with the Atbash cipher.
pub fn decode(cipher: &str) -> String {
unimplemented!("Decoding of {cipher:?} in Atbash cipher.");
todo!("Decoding of {cipher:?} in Atbash cipher.");
}
4 changes: 2 additions & 2 deletions exercises/practice/beer-song/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pub fn verse(n: u32) -> String {
unimplemented!("emit verse {n}")
todo!("emit verse {n}")
}

pub fn sing(start: u32, end: u32) -> String {
unimplemented!("sing verses {start} to {end}, inclusive")
todo!("sing verses {start} to {end}, inclusive")
}
2 changes: 1 addition & 1 deletion exercises/practice/binary-search/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pub fn find(array: &[i32], key: i32) -> Option<usize> {
unimplemented!(
todo!(
"Using the binary search algorithm, find the element '{key}' in the array '{array:?}' and return its index."
);
}
2 changes: 1 addition & 1 deletion exercises/practice/bob/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
pub fn reply(message: &str) -> &str {
unimplemented!("have Bob reply to the incoming message: {message}")
todo!("have Bob reply to the incoming message: {message}")
}
2 changes: 1 addition & 1 deletion exercises/practice/book-store/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
pub fn lowest_price(books: &[u32]) -> u32 {
unimplemented!("Find the lowest price of the bookbasket with books {books:?}")
todo!("Find the lowest price of the bookbasket with books {books:?}")
}
6 changes: 3 additions & 3 deletions exercises/practice/bowling/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ pub struct BowlingGame {}

impl BowlingGame {
pub fn new() -> Self {
unimplemented!();
todo!();
}

pub fn roll(&mut self, pins: u16) -> Result<(), Error> {
unimplemented!("Record that {pins} pins have been scored");
todo!("Record that {pins} pins have been scored");
}

pub fn score(&self) -> Option<u16> {
unimplemented!("Return the score if the game is complete, or None if not.");
todo!("Return the score if the game is complete, or None if not.");
}
}
Loading

0 comments on commit 7949362

Please sign in to comment.