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" + ] +} 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();