Skip to content

Commit

Permalink
clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
LemonInTheDark committed Apr 27, 2024
1 parent 12f3786 commit 30f9050
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 30 deletions.
2 changes: 0 additions & 2 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
[target.x86_64-pc-windows-msvc]
rustflags = ["-C", "target-feature=+crt-static"]

[target.x86_64-unknown-linux-musl]
rustflags = ["-C", "target-feature=+crt-static"]
12 changes: 6 additions & 6 deletions hypnagogic_cli/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ pub enum Error {
expected_path: PathBuf,
},
#[error("Image Parsing Failed")]
InputError(#[from] InputError),
InputParsingFailed(#[from] InputError),
#[error("Processing Failed")]
ProcessorFailed(#[from] ProcessorError),
#[error("Output Failed")]
OutputError(#[from] OutputError),
OutputWriteFailed(#[from] OutputError),
#[error("No template folder")]
NoTemplateFolder(PathBuf),
#[error("Generic IO Error")]
Expand Down Expand Up @@ -82,9 +82,9 @@ impl UFE for Error {
format!("Expected template folder at {folder:?}"),
])
}
Error::InputError(image_error) => image_error.reasons(),
Error::InputParsingFailed(image_error) => image_error.reasons(),
Error::ProcessorFailed(process_error) => process_error.reasons(),
Error::OutputError(output_error) => output_error.reasons(),
Error::OutputWriteFailed(output_error) => output_error.reasons(),
Error::IO(err) => {
Some(vec![format!(
"Operation failed for reason of \"{:?}\"",
Expand Down Expand Up @@ -121,9 +121,9 @@ impl UFE for Error {
.to_string(),
)
}
Error::InputError(image_error) => image_error.helptext(),
Error::InputParsingFailed(image_error) => image_error.helptext(),
Error::ProcessorFailed(process_error) => process_error.helptext(),
Error::OutputError(output_error) => output_error.helptext(),
Error::OutputWriteFailed(output_error) => output_error.helptext(),
Error::IO(_) => {
Some(
"Make sure the directories or files aren't in use, and you have permission to \
Expand Down
16 changes: 8 additions & 8 deletions hypnagogic_core/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,12 @@ mod test {
third = 1
"#;

let second_string = r#"
let second_string = r"
first = 2
second = 2
third = 2
fourth = 2
"#;
";

let third_string = r#"
template = "fourth"
Expand All @@ -136,15 +136,15 @@ mod test {
inner_2 = 3
"#;

let fourth_string = r#"
let fourth_string = r"
first = 4
second = 4
third = 4
[inner]
inner_1 = 4
inner_2 = 4
inner_3 = 4
"#;
";

Ok(toml::from_str(match input {
"first" => first_string,
Expand Down Expand Up @@ -173,12 +173,12 @@ mod test {

let result = resolve_templates(input, TestResolver).unwrap();

let expected_string = r#"
let expected_string = r"
first = 10
second = 10
third = 1
fourth = 2
"#;
";
let expected: Value = toml::from_str(expected_string).unwrap();
assert_eq!(result, expected);
}
Expand All @@ -197,15 +197,15 @@ mod test {

let result = resolve_templates(input, TestResolver).unwrap();

let expected_string = r#"
let expected_string = r"
first = 10
second = 10
third = 3
[inner]
inner_1 = 10
inner_2 = 3
inner_3 = 4
"#;
";
let expected_value: Value = toml::from_str(expected_string).unwrap();
assert_eq!(result, expected_value);
}
Expand Down
2 changes: 1 addition & 1 deletion hypnagogic_core/src/generation/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub enum GenerationError {

impl UFE for GenerationError {
fn summary(&self) -> String {
format!("{}", self)
format!("{self}")
}

fn reasons(&self) -> Option<Vec<String>> {
Expand Down
2 changes: 1 addition & 1 deletion hypnagogic_core/src/operations/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub type ProcessorResult<T> = Result<T, ProcessorError>;

impl UFE for ProcessorError {
fn summary(&self) -> String {
format!("{}", self)
format!("{self}")
}

fn reasons(&self) -> Option<Vec<String>> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ impl IconOperationConfig for BitmaskSliceReconstruct {
});
}
}
if problem_states.len() > 0 {
if !problem_states.is_empty() {
return Err(ProcessorError::from(
RestrorationError::InconsistentDelays {
expected: delays.unwrap_or_default(),
Expand Down
4 changes: 2 additions & 2 deletions hypnagogic_core/src/operations/format_converter/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub enum RestrorationError {

impl UFE for RestrorationError {
fn summary(&self) -> String {
format!("{}", self)
format!("{self}")
}

fn reasons(&self) -> Option<Vec<String>> {
Expand Down Expand Up @@ -54,7 +54,7 @@ impl UFE for RestrorationError {
text_delays(&problem.delays, "ds")
));
}
return Some(hand_back);
Some(hand_back)
}
}
}
Expand Down
10 changes: 4 additions & 6 deletions hypnagogic_core/src/operations/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub enum InputError {

impl UFE for InputError {
fn summary(&self) -> String {
format!("{}", self)
format!("{self}")
}

fn reasons(&self) -> Option<Vec<String>> {
Expand All @@ -51,8 +51,7 @@ impl UFE for InputError {
InputError::UnsupportedFormat(_) => {
Some("Are you using a valid image format?".to_string())
}
InputError::DynamicRead(_) => None,
InputError::DmiRead(_) => None,
InputError::DynamicRead(_) | InputError::DmiRead(_) => None,
}
}
}
Expand Down Expand Up @@ -168,7 +167,7 @@ pub enum OutputError {

impl UFE for OutputError {
fn summary(&self) -> String {
format!("{}", self)
format!("{self}")
}

fn reasons(&self) -> Option<Vec<String>> {
Expand All @@ -180,8 +179,7 @@ impl UFE for OutputError {

fn helptext(&self) -> Option<String> {
match self {
OutputError::DynamicWrite(_) => None,
OutputError::DmiWrite(_) => None,
OutputError::DynamicWrite(_) | OutputError::DmiWrite(_) => None,
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion hypnagogic_core/src/util/adjacency.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ mod tests {

let result = adj.set_flags_vec();

let expected = vec![Adjacency::N, Adjacency::W, Adjacency::S];
let expected = [Adjacency::N, Adjacency::W, Adjacency::S];

assert!(expected.iter().all(|item| result.contains(item)));
}
Expand Down
4 changes: 2 additions & 2 deletions hypnagogic_core/src/util/delays.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// Takes a list of delays and a suffix as input, returns a set of textified
// delays
pub fn text_delays(textify: &Vec<f32>, suffix: &str) -> String {
#[must_use] pub fn text_delays(textify: &[f32], suffix: &str) -> String {
format!(
"[{}]",
textify
.into_iter()
.iter()
.map(|ds| format!("{ds}{suffix}"))
.reduce(|acc, text_ds| format!("{acc}, {text_ds}"))
.unwrap_or_default()
Expand Down

0 comments on commit 30f9050

Please sign in to comment.