From 94e7f1d8c40c7236524ed5da7f3c8bd127144c8a Mon Sep 17 00:00:00 2001 From: Bruce Mitchener Date: Sun, 29 Sep 2024 16:20:34 +0700 Subject: [PATCH 1/2] chore: cargo fmt --- src/wrap_algorithms.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/wrap_algorithms.rs b/src/wrap_algorithms.rs index 7737e08..28a7571 100644 --- a/src/wrap_algorithms.rs +++ b/src/wrap_algorithms.rs @@ -344,10 +344,7 @@ impl Default for WrapAlgorithm { /// /// Apologies to anyone who actually knows how to build a house and /// knows how long each step takes :-) -pub fn wrap_first_fit<'a, T: Fragment>( - fragments: &'a [T], - line_widths: &[f64], -) -> Vec<&'a [T]> { +pub fn wrap_first_fit<'a, T: Fragment>(fragments: &'a [T], line_widths: &[f64]) -> Vec<&'a [T]> { // The final line width is used for all remaining lines. let default_line_width = line_widths.last().copied().unwrap_or(0.0); let mut lines = Vec::new(); From 0609c60b48640d6fdd70e5a7cd468296c41bb058 Mon Sep 17 00:00:00 2001 From: Bruce Mitchener Date: Sun, 29 Sep 2024 19:27:48 +0700 Subject: [PATCH 2/2] chore(ci): Check formatting Uses the same check / action as in `smawk`. --- .github/workflows/build.yml | 18 ++++++++++++++++++ dprint.json | 19 +++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 dprint.json diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e753e15..980e84e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -270,3 +270,21 @@ jobs: - name: Deploy textwrap-wasm-demo-app if: steps.git-add.outputs.has-changes == 'true' run: git push origin + + format: + name: Format + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + # We use an unstable rustfmt feature and we thus need the + # nightly channel to enforce the formatting. + - name: Setup Rust nightly + run: rustup default nightly + + - name: Install rustfmt + run: rustup component add rustfmt + + - name: Check Formatting + uses: dprint/check@v2.2 diff --git a/dprint.json b/dprint.json new file mode 100644 index 0000000..e48af5f --- /dev/null +++ b/dprint.json @@ -0,0 +1,19 @@ +{ + "markdown": { + "textWrap": "always" + }, + "exec": { + "commands": [{ + "command": "rustfmt", + "exts": ["rs"] + }] + }, + "excludes": ["target/"], + "plugins": [ + "https://plugins.dprint.dev/json-0.17.4.wasm", + "https://plugins.dprint.dev/markdown-0.16.1.wasm", + "https://plugins.dprint.dev/toml-0.5.4.wasm", + "https://plugins.dprint.dev/exec-0.4.3.json@42343548b8022c99b1d750be6b894fe6b6c7ee25f72ae9f9082226dd2e515072", + "https://plugins.dprint.dev/prettier-0.27.0.json@3557a62b4507c55a47d8cde0683195b14d13c41dda66d0f0b0e111aed107e2fe" + ] +}