Skip to content

Commit

Permalink
chore: Simplify newtype to tuple struct
Browse files Browse the repository at this point in the history
  • Loading branch information
alexpovel committed Sep 13, 2023
1 parent 634aee0 commit 30fab29
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
4 changes: 2 additions & 2 deletions benches/threading.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ pub fn process_multi_threaded_german(
// }

let stage = GermanStage;
let result = stage.substitute(&item).unwrap();
let result: String = stage.substitute(&item).unwrap().into();

let mut results = results_clone.lock().unwrap();
info!("Thread {} finished processing line", i);
Expand All @@ -73,7 +73,7 @@ pub fn process_multi_threaded_german(
let mut results = Arc::try_unwrap(results).unwrap().into_inner().unwrap();
results.sort_by_key(|&(index, _)| index);

let results: Vec<String> = results.into_iter().map(|(_, result)| result.0).collect();
let results: Vec<String> = results.into_iter().map(|(_, result)| result).collect();

destination.write_all(results.join("\n").as_bytes())
}
Expand Down
4 changes: 2 additions & 2 deletions src/stages/german/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -566,8 +566,8 @@ mod tests {
word: String
) (|data: &TestProcess| {
let input = word.clone();
let result = GermanStage{}.substitute(&input).unwrap();
insta::assert_yaml_snapshot!(data.to_string(), result.0);
let result: String = GermanStage{}.substitute(&input).unwrap().into();
insta::assert_yaml_snapshot!(data.to_string(), result);
}
)
}
Expand Down
5 changes: 1 addition & 4 deletions src/stages/tooling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@ impl std::fmt::Display for StageError {
/// [newtype](https://doc.rust-lang.org/rust-by-example/generics/new_types.html), used
/// for increased clarity.
#[derive(Debug)]
pub struct SubstitutedString(
/// The actual string contents.
pub String,
);
pub struct SubstitutedString(String);

/// Convert a [`SubstitutedString`] into a [`String`].
///
Expand Down

0 comments on commit 30fab29

Please sign in to comment.