Skip to content

Commit e413f3c

Browse files
committed
use inline format arguments for unimplemented!
The Clippy lint doesn't check unimplemented!, but I think its failure to do so is a mistake, since unimplemented! also uses format!. Therefore, we should use inline format arguments. https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args Non-inlined code is slightly more difficult to read and understand, as it requires arguments to be matched against the format string. The inlined syntax, where allowed, is simpler.
1 parent 9094998 commit e413f3c

File tree

91 files changed

+124
-244
lines changed

Some content is hidden

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

91 files changed

+124
-244
lines changed
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+
unimplemented!("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+
unimplemented!("calculate the amount of working items at speed: {speed}")
77
}

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,7 @@ impl CsvRecordBuilder {
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!(
18-
"implement the `CsvRecordBuilder::add` method, adding {}",
19-
val
20-
)
17+
unimplemented!("implement the `CsvRecordBuilder::add` method, adding {val}")
2118
}
2219

2320
/// Consumes the builder and returns the comma separated list

exercises/concept/lucians-luscious-lasagna/src/lib.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,16 @@ pub fn expected_minutes_in_oven() -> i32 {
44

55
pub fn remaining_minutes_in_oven(actual_minutes_in_oven: i32) -> i32 {
66
unimplemented!(
7-
"calculate remaining minutes in oven given actual minutes in oven: {}",
8-
actual_minutes_in_oven
7+
"calculate remaining minutes in oven given actual minutes in oven: {actual_minutes_in_oven}"
98
)
109
}
1110

1211
pub fn preparation_time_in_minutes(number_of_layers: i32) -> i32 {
13-
unimplemented!(
14-
"calculate preparation time in minutes for number of layers: {}",
15-
number_of_layers
16-
)
12+
unimplemented!("calculate preparation time in minutes for number of layers: {number_of_layers}")
1713
}
1814

1915
pub fn elapsed_time_in_minutes(number_of_layers: i32, actual_minutes_in_oven: i32) -> i32 {
2016
unimplemented!(
21-
"calculate elapsed time in minutes for number of layers {} and actual minutes in oven {}",
22-
number_of_layers,
23-
actual_minutes_in_oven
17+
"calculate elapsed time in minutes for number of layers {number_of_layers} and actual minutes in oven {actual_minutes_in_oven}"
2418
)
2519
}

exercises/concept/resistor-color/src/lib.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@ pub fn color_to_value(color: ResistorColor) -> u32 {
1717
}
1818

1919
pub fn value_to_color_string(value: u32) -> String {
20-
unimplemented!(
21-
"convert the value {} into a string representation of color",
22-
value
23-
)
20+
unimplemented!("convert the value {value} into a string representation of color")
2421
}
2522

2623
pub fn colors() -> Vec<ResistorColor> {

exercises/concept/role-playing-game/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ impl Player {
1010
}
1111

1212
pub fn cast_spell(&mut self, mana_cost: u32) -> u32 {
13-
unimplemented!("Cast a spell of cost {}", mana_cost)
13+
unimplemented!("Cast a spell of cost {mana_cost}")
1414
}
1515
}

exercises/concept/rpn-calculator/.docs/instructions.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,7 @@ pub enum CalculatorInput {
106106

107107
pub fn evaluate(inputs: &[CalculatorInput]) -> Option<i32> {
108108
unimplemented!(
109-
"Given the inputs: {:?}, evaluate them as though they were a Reverse Polish notation expression",
110-
inputs,
109+
"Given the inputs: {inputs:?}, evaluate them as though they were a Reverse Polish notation expression"
111110
);
112111
}
113112
```

exercises/concept/rpn-calculator/src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ pub enum CalculatorInput {
99

1010
pub fn evaluate(inputs: &[CalculatorInput]) -> Option<i32> {
1111
unimplemented!(
12-
"Given the inputs: {:?}, evaluate them as though they were a Reverse Polish notation expression",
13-
inputs,
12+
"Given the inputs: {inputs:?}, evaluate them as though they were a Reverse Polish notation expression"
1413
);
1514
}

exercises/concept/short-fibonacci/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ pub fn create_empty() -> Vec<u8> {
77
///
88
/// Applications often use buffers when serializing data to send over the network.
99
pub fn create_buffer(count: usize) -> Vec<u8> {
10-
unimplemented!("create a zeroized buffer of {} bytes", count)
10+
unimplemented!("create a zeroized buffer of {count} bytes")
1111
}
1212

1313
/// Create a vector containing the first five elements of the Fibonacci sequence.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
/// What should the type of _function be?
22
pub fn map(input: Vec<i32>, _function: ???) -> Vec<i32> {
3-
unimplemented!("Transform input vector {:?} using passed function", input);
3+
unimplemented!("Transform input vector {input:?} using passed function");
44
}

exercises/practice/acronym/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
pub fn abbreviate(phrase: &str) -> String {
2-
unimplemented!("Given the phrase '{}', return its acronym", phrase);
2+
unimplemented!("Given the phrase '{phrase}', return its acronym");
33
}

0 commit comments

Comments
 (0)