Skip to content

Commit

Permalink
Update to rust 2021 and small clippy cleanups (#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
dylanowen authored Jan 31, 2023
1 parent fd0e754 commit 5c2daca
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,4 @@ jobs:
- uses: actions-rs/cargo@v1
with:
command: clippy
args: -- -D warnings
args: --all-targets --all-features -- -D warnings
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ readme = "Readme.md"
license = "MPL-2.0"
homepage = "https://github.com/dylanowen/mdbook-graphviz"
repository = "https://github.com/dylanowen/mdbook-graphviz"
edition = "2018"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand Down
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ SHELL:=/bin/bash
.DEFAULT_GOAL := default

fix:
cargo fix --allow-staged
cargo fix --all-targets --all-features --allow-staged
cargo clippy --fix --all-targets --all-features --allow-staged

fmt:
cargo fmt --all -- --check

lint:
cargo clippy -- -D warnings
cargo clippy --all-targets --all-features -- -D warnings
-cargo audit

check:
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ fn main() {
if let Some(sub_args) = matches.subcommand_matches("supports") {
handle_supports(&preprocessor, sub_args);
} else if let Err(e) = handle_preprocessing(&preprocessor) {
eprintln!("{}", e);
eprintln!("{e}");
process::exit(1);
}
}
Expand Down
26 changes: 9 additions & 17 deletions src/preprocessor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ impl GraphvizBlock {
)
};

format!("{}.svg", image_name)
format!("{image_name}.svg")
}

pub fn output_path(&self) -> PathBuf {
Expand Down Expand Up @@ -301,7 +301,7 @@ mod test {
} = block;

Ok(vec![Event::Text(
format!("{}|{:?}|{}|{}", file_name, output_path, graph_name, index).into(),
format!("{file_name}|{output_path:?}|{graph_name}|{index}").into(),
)])
}
}
Expand Down Expand Up @@ -335,8 +335,7 @@ digraph Test {
let expected = format!(
r#"# Chapter
{}_0.generated.svg|"/./book/{}_0.generated.svg"||0"#,
NORMALIZED_CHAPTER_NAME, NORMALIZED_CHAPTER_NAME
{NORMALIZED_CHAPTER_NAME}_0.generated.svg|"/./book/{NORMALIZED_CHAPTER_NAME}_0.generated.svg"||0"#
);

let chapter = process_chapter(chapter).await.unwrap();
Expand All @@ -359,8 +358,7 @@ digraph Test {
let expected = format!(
r#"# Chapter
{}_graph_name_0.generated.svg|"/./book/{}_graph_name_0.generated.svg"|Graph Name|0"#,
NORMALIZED_CHAPTER_NAME, NORMALIZED_CHAPTER_NAME
{NORMALIZED_CHAPTER_NAME}_graph_name_0.generated.svg|"/./book/{NORMALIZED_CHAPTER_NAME}_graph_name_0.generated.svg"|Graph Name|0"#
);

let chapter = process_chapter(chapter).await.unwrap();
Expand Down Expand Up @@ -392,8 +390,7 @@ digraph Test {
/*asteriks/*
( \int x dx = \frac{{x^2}}{{2}} + C)
{}_graph_name_0.generated.svg|"/./book/{}_graph_name_0.generated.svg"|Graph Name|0"#,
NORMALIZED_CHAPTER_NAME, NORMALIZED_CHAPTER_NAME
{NORMALIZED_CHAPTER_NAME}_graph_name_0.generated.svg|"/./book/{NORMALIZED_CHAPTER_NAME}_graph_name_0.generated.svg"|Graph Name|0"#
);

let chapter = process_chapter(chapter).await.unwrap();
Expand Down Expand Up @@ -429,8 +426,7 @@ digraph Test {
|col 2 is|centered|$12|
|col 3 is|right-aligned|$1|
{}_graph_name_0.generated.svg|"/./book/{}_graph_name_0.generated.svg"|Graph Name|0"#,
NORMALIZED_CHAPTER_NAME, NORMALIZED_CHAPTER_NAME
{NORMALIZED_CHAPTER_NAME}_graph_name_0.generated.svg|"/./book/{NORMALIZED_CHAPTER_NAME}_graph_name_0.generated.svg"|Graph Name|0"#
);

let chapter = process_chapter(chapter).await.unwrap();
Expand Down Expand Up @@ -483,9 +479,7 @@ digraph Test {

assert!(
duration < SLEEP_DURATION * 2,
"{:?} should be less than 2 * {:?} since we expect some variation when running",
duration,
SLEEP_DURATION
"{duration:?} should be less than 2 * {SLEEP_DURATION:?} since we expect some variation when running"
);
}

Expand All @@ -508,8 +502,7 @@ digraph Test {
let expected = format!(
r#"# Chapter
{}_graph_name_0.generated.svg|"/./book/{}_graph_name_0.generated.svg"|Graph Name|0"#,
NORMALIZED_CHAPTER_NAME, NORMALIZED_CHAPTER_NAME
{NORMALIZED_CHAPTER_NAME}_graph_name_0.generated.svg|"/./book/{NORMALIZED_CHAPTER_NAME}_graph_name_0.generated.svg"|Graph Name|0"#
);

let mut chapter = process_chapter(chapter).await.unwrap();
Expand Down Expand Up @@ -548,8 +541,7 @@ digraph Test {
BookItem::Chapter(new_chapter(format!(
r#"# Chapter
{}_graph_name_0.generated.svg|"/./book/{}_graph_name_0.generated.svg"|Graph Name|0"#,
NORMALIZED_CHAPTER_NAME, NORMALIZED_CHAPTER_NAME
{NORMALIZED_CHAPTER_NAME}_graph_name_0.generated.svg|"/./book/{NORMALIZED_CHAPTER_NAME}_graph_name_0.generated.svg"|Graph Name|0"#
)))
]
)
Expand Down
2 changes: 1 addition & 1 deletion src/renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ fn format_output(output: String) -> String {
let output = NEW_LINE_TAGS_RE.replace_all(&output, "><");
let output = output.trim();

format!("<div>{}</div>", output)
format!("<div>{output}</div>")
}

#[cfg(test)]
Expand Down

0 comments on commit 5c2daca

Please sign in to comment.