diff --git a/.clippy.toml b/.clippy.toml index e88edc91..1d4c5dc6 100644 --- a/.clippy.toml +++ b/.clippy.toml @@ -1,5 +1,4 @@ -msrv = "1.70.0" # MSRV -warn-on-all-wildcard-imports = true +allow-print-in-tests = true allow-expect-in-tests = true allow-unwrap-in-tests = true allow-dbg-in-tests = true diff --git a/.github/renovate.json5 b/.github/renovate.json5 index 24414f38..c1844208 100644 --- a/.github/renovate.json5 +++ b/.github/renovate.json5 @@ -3,6 +3,7 @@ 'before 5am on the first day of the month', ], semanticCommits: 'enabled', + commitMessageLowerCase: 'never', configMigration: true, dependencyDashboard: true, customManagers: [ @@ -17,29 +18,28 @@ '^\\.github/workflows/rust-next.yml$', ], matchStrings: [ - 'MSRV.*?(?\\d+\\.\\d+(\\.\\d+)?)', - '(?\\d+\\.\\d+(\\.\\d+)?).*?MSRV', + 'STABLE.*?(?\\d+\\.\\d+(\\.\\d+)?)', + '(?\\d+\\.\\d+(\\.\\d+)?).*?STABLE', ], - depNameTemplate: 'rust', + depNameTemplate: 'STABLE', packageNameTemplate: 'rust-lang/rust', datasourceTemplate: 'github-releases', }, ], packageRules: [ { - commitMessageTopic: 'MSRV', + commitMessageTopic: 'Rust Stable', matchManagers: [ 'custom.regex', ], matchPackageNames: [ - 'rust', + 'STABLE', ], - minimumReleaseAge: '252 days', // 6 releases * 6 weeks per release * 7 days per week - internalChecksFilter: 'strict', extractVersion: '^(?\\d+\\.\\d+)', // Drop the patch version schedule: [ '* * * * *', ], + automerge: true, }, // Goals: // - Keep version reqs low, ignoring compatible normal/build dependencies @@ -72,6 +72,7 @@ matchCurrentVersion: '>=1.0.0', matchUpdateTypes: [ 'minor', + 'patch', ], enabled: false, }, @@ -99,6 +100,7 @@ matchCurrentVersion: '>=1.0.0', matchUpdateTypes: [ 'minor', + 'patch', ], automerge: true, groupName: 'compatible (dev)', diff --git a/.github/settings.yml b/.github/settings.yml index d4136766..d126ed82 100644 --- a/.github/settings.yml +++ b/.github/settings.yml @@ -52,14 +52,18 @@ labels: color: '#02E10C' description: "Help wanted!" -branches: - - name: main - protection: - required_pull_request_reviews: null - required_conversation_resolution: true - required_status_checks: - # Required. Require branches to be up to date before merging. - strict: false - contexts: ["CI", "Lint Commits", "Spell Check with Typos"] - enforce_admins: false - restrictions: null +# This serves more as documentation. +# Branch protection API was replaced by rulesets but settings isn't updated. +# See https://github.com/repository-settings/app/issues/825 +# +# branches: +# - name: main +# protection: +# required_pull_request_reviews: null +# required_conversation_resolution: true +# required_status_checks: +# # Required. Require branches to be up to date before merging. +# strict: false +# contexts: ["CI", "Spell Check with Typos"] +# enforce_admins: false +# restrictions: null diff --git a/.github/workflows/audit.yml b/.github/workflows/audit.yml index ccee1fef..07c70eeb 100644 --- a/.github/workflows/audit.yml +++ b/.github/workflows/audit.yml @@ -17,6 +17,10 @@ env: CARGO_TERM_COLOR: always CLICOLOR: 1 +concurrency: + group: "${{ github.workflow }}-${{ github.ref }}" + cancel-in-progress: true + jobs: security_audit: permissions: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e1e6b0c4..4c5d7586 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,21 +14,27 @@ env: CARGO_TERM_COLOR: always CLICOLOR: 1 +concurrency: + group: "${{ github.workflow }}-${{ github.ref }}" + cancel-in-progress: true + jobs: ci: permissions: contents: none name: CI - needs: [test, msrv, docs, rustfmt, clippy] + needs: [test, msrv, lockfile, docs, rustfmt, clippy] runs-on: ubuntu-latest + if: "always()" steps: - - name: Done - run: exit 0 + - name: Failed + run: exit 1 + if: "contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') || contains(needs.*.result, 'skipped')" test: name: Test strategy: matrix: - os: ["ubuntu-latest", "windows-latest", "macos-latest"] + os: ["ubuntu-latest", "windows-latest", "macos-14"] rust: ["stable"] continue-on-error: ${{ matrix.rust != 'stable' }} runs-on: ${{ matrix.os }} @@ -41,16 +47,13 @@ jobs: toolchain: ${{ matrix.rust }} components: rustfmt - uses: Swatinem/rust-cache@v2 + - uses: taiki-e/install-action@cargo-hack - name: Build - run: cargo test --no-run --workspace --all-features - - name: Default features - run: cargo test --workspace - - name: All features - run: cargo test --workspace --all-features - - name: No-default features - run: cargo test --workspace --no-default-features + run: cargo test --workspace --no-run + - name: Test + run: cargo hack test --feature-powerset --workspace msrv: - name: "Check MSRV: 1.70.0" + name: "Check MSRV" runs-on: ubuntu-latest steps: - name: Checkout repository @@ -58,16 +61,11 @@ jobs: - name: Install Rust uses: dtolnay/rust-toolchain@stable with: - toolchain: "1.70" # MSRV + toolchain: stable - uses: Swatinem/rust-cache@v2 + - uses: taiki-e/install-action@cargo-hack - name: Default features - run: cargo check --workspace --all-targets - - name: All features - run: cargo check --workspace --all-targets --all-features - - name: No-default features - run: cargo check --workspace --all-targets --no-default-features - - name: no_std - run: cargo check -p anstyle --no-default-features + run: cargo hack check --feature-powerset --locked --rust-version --ignore-private --workspace lockfile: runs-on: ubuntu-latest steps: @@ -79,7 +77,7 @@ jobs: toolchain: stable - uses: Swatinem/rust-cache@v2 - name: "Is lockfile updated?" - run: cargo fetch --locked + run: cargo update --workspace --locked docs: name: Docs runs-on: ubuntu-latest @@ -89,7 +87,7 @@ jobs: - name: Install Rust uses: dtolnay/rust-toolchain@stable with: - toolchain: stable + toolchain: "1.77" # STABLE - uses: Swatinem/rust-cache@v2 - name: Check documentation env: @@ -104,9 +102,7 @@ jobs: - name: Install Rust uses: dtolnay/rust-toolchain@stable with: - # Not MSRV because its harder to jump between versions and people are - # more likely to have stable - toolchain: stable + toolchain: "1.77" # STABLE components: rustfmt - uses: Swatinem/rust-cache@v2 - name: Check formatting @@ -122,13 +118,13 @@ jobs: - name: Install Rust uses: dtolnay/rust-toolchain@stable with: - toolchain: "1.70" # MSRV + toolchain: "1.77" # STABLE components: clippy - uses: Swatinem/rust-cache@v2 - name: Install SARIF tools - run: cargo install clippy-sarif --version 0.3.4 --locked # Held back due to msrv + run: cargo install clippy-sarif --locked - name: Install SARIF tools - run: cargo install sarif-fmt --version 0.3.4 --locked # Held back due to msrv + run: cargo install sarif-fmt --locked - name: Check run: > cargo clippy --workspace --all-features --all-targets --message-format=json -- -D warnings --allow deprecated @@ -143,3 +139,22 @@ jobs: wait-for-processing: true - name: Report status run: cargo clippy --workspace --all-features --all-targets -- -D warnings --allow deprecated + coverage: + name: Coverage + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Install Rust + uses: dtolnay/rust-toolchain@stable + with: + toolchain: stable + - uses: Swatinem/rust-cache@v2 + - name: Install cargo-tarpaulin + run: cargo install cargo-tarpaulin + - name: Gather coverage + run: cargo tarpaulin --output-dir coverage --out lcov + - name: Publish to Coveralls + uses: coverallsapp/github-action@master + with: + github-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/committed.yml b/.github/workflows/committed.yml index 04625584..e7a50fbb 100644 --- a/.github/workflows/committed.yml +++ b/.github/workflows/committed.yml @@ -11,6 +11,10 @@ env: CARGO_TERM_COLOR: always CLICOLOR: 1 +concurrency: + group: "${{ github.workflow }}-${{ github.ref }}" + cancel-in-progress: true + jobs: committed: name: Lint Commits diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index 95514075..1b000abf 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -12,6 +12,10 @@ env: CARGO_TERM_COLOR: always CLICOLOR: 1 +concurrency: + group: "${{ github.workflow }}-${{ github.ref }}" + cancel-in-progress: true + jobs: pre-commit: permissions: @@ -20,4 +24,4 @@ jobs: steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 - - uses: pre-commit/action@v3.0.0 + - uses: pre-commit/action@v3.0.1 diff --git a/.github/workflows/rust-next.yml b/.github/workflows/rust-next.yml index 1389d980..b8265520 100644 --- a/.github/workflows/rust-next.yml +++ b/.github/workflows/rust-next.yml @@ -12,12 +12,16 @@ env: CARGO_TERM_COLOR: always CLICOLOR: 1 +concurrency: + group: "${{ github.workflow }}-${{ github.ref }}" + cancel-in-progress: true + jobs: test: name: Test strategy: matrix: - os: ["ubuntu-latest", "windows-latest", "macos-latest"] + os: ["ubuntu-latest", "windows-latest", "macos-latest", "macos-14"] rust: ["stable", "beta"] include: - os: ubuntu-latest @@ -33,12 +37,11 @@ jobs: toolchain: ${{ matrix.rust }} components: rustfmt - uses: Swatinem/rust-cache@v2 - - name: Default features - run: cargo test --workspace - - name: All features - run: cargo test --workspace --all-features - - name: No-default features - run: cargo test --workspace --no-default-features + - uses: taiki-e/install-action@cargo-hack + - name: Build + run: cargo test --workspace --no-run + - name: Test + run: cargo hack test --feature-powerset --workspace latest: name: "Check latest dependencies" runs-on: ubuntu-latest @@ -51,11 +54,10 @@ jobs: toolchain: stable components: rustfmt - uses: Swatinem/rust-cache@v2 + - uses: taiki-e/install-action@cargo-hack - name: Update dependencues run: cargo update - - name: Default features - run: cargo test --workspace --all-targets - - name: All features - run: cargo test --workspace --all-targets --all-features - - name: No-default features - run: cargo test --workspace --all-targets --no-default-features + - name: Build + run: cargo test --workspace --no-run + - name: Test + run: cargo hack test --feature-powerset --workspace diff --git a/.github/workflows/spelling.yml b/.github/workflows/spelling.yml index 12f75859..8e58d9ec 100644 --- a/.github/workflows/spelling.yml +++ b/.github/workflows/spelling.yml @@ -10,6 +10,10 @@ env: CARGO_TERM_COLOR: always CLICOLOR: 1 +concurrency: + group: "${{ github.workflow }}-${{ github.ref }}" + cancel-in-progress: true + jobs: spelling: name: Spell Check with Typos diff --git a/Cargo.lock b/Cargo.lock index 8c9e2be6..d5ce53c3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,12 +2,6 @@ # It is not intended for manual editing. version = 3 -[[package]] -name = "anes" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299" - [[package]] name = "ansi_term" version = "0.12.1" @@ -19,28 +13,44 @@ dependencies = [ [[package]] name = "anstream" -version = "0.6.11" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e2e1ebcb11de5c03c67de28a7df593d32191b44939c482e97702baaaa6ab6a5" +checksum = "0ca84f3628370c59db74ee214b3263d58f9aadd9b4fe7e711fd87dc452b7f163" dependencies = [ - "anstyle 1.0.0", - "anstyle-parse 0.2.0", + "anstyle 1.0.2", + "anstyle-parse 0.2.1", "anstyle-query 1.0.0", - "anstyle-wincon 3.0.1", - "colorchoice 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "anstyle-wincon 1.0.2", + "colorchoice 1.0.0", + "is-terminal", "utf8parse", ] [[package]] name = "anstream" version = "0.6.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d96bd03f33fe50a863e394ee9718a706f988b9079b20c3784fb726e7678b62fb" dependencies = [ - "anstyle 1.0.6", - "anstyle-parse 0.2.3", - "anstyle-query 1.0.2", + "anstyle 1.0.2", + "anstyle-parse 0.2.1", + "anstyle-query 1.0.0", "anstyle-wincon 3.0.2", "colorchoice 1.0.0", - "criterion", + "utf8parse", +] + +[[package]] +name = "anstream" +version = "0.6.14" +dependencies = [ + "anstyle 1.0.7", + "anstyle-parse 0.2.4", + "anstyle-query 1.0.3", + "anstyle-wincon 3.0.3", + "colorchoice 1.0.1", + "divan", + "is_terminal_polyfill", "lexopt", "owo-colors", "proptest", @@ -50,74 +60,74 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41ed9a86bf92ae6580e0a31281f65a1b1d867c0cc68d5346e2ae128dddfa6a7d" +checksum = "15c4c2c83f81532e5845a733998b6971faca23490340a418e9b72a3ec9de12ea" [[package]] name = "anstyle" -version = "1.0.6" +version = "1.0.7" dependencies = [ "lexopt", ] [[package]] name = "anstyle-ansi-term" -version = "1.0.0" +version = "1.0.1" dependencies = [ "ansi_term", - "anstyle 1.0.6", + "anstyle 1.0.7", ] [[package]] name = "anstyle-crossterm" -version = "2.0.0" +version = "2.0.1" dependencies = [ - "anstyle 1.0.6", + "anstyle 1.0.7", "crossterm", ] [[package]] name = "anstyle-git" -version = "1.0.0" +version = "1.0.1" dependencies = [ - "anstyle 1.0.6", + "anstyle 1.0.7", ] [[package]] name = "anstyle-lossy" -version = "1.1.0" +version = "1.1.1" dependencies = [ - "anstyle 1.0.6", + "anstyle 1.0.7", ] [[package]] name = "anstyle-ls" -version = "1.0.1" +version = "1.0.2" dependencies = [ - "anstyle 1.0.6", + "anstyle 1.0.7", ] [[package]] name = "anstyle-owo-colors" -version = "2.0.0" +version = "2.0.1" dependencies = [ - "anstyle 1.0.6", + "anstyle 1.0.7", "owo-colors", ] [[package]] name = "anstyle-parse" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e765fd216e48e067936442276d1d57399e37bce53c264d6fefbe298080cb57ee" +checksum = "938874ff5980b03a87c5524b3ae5b59cf99b1d6bc836848df7bc5ada9643c333" dependencies = [ "utf8parse", ] [[package]] name = "anstyle-parse" -version = "0.2.3" +version = "0.2.4" dependencies = [ "arrayvec", "codegenrs", @@ -139,16 +149,16 @@ dependencies = [ [[package]] name = "anstyle-query" -version = "1.0.2" +version = "1.0.3" dependencies = [ "windows-sys 0.52.0", ] [[package]] name = "anstyle-roff" -version = "0.3.2" +version = "0.3.3" dependencies = [ - "anstyle 1.0.6", + "anstyle 1.0.7", "anstyle-lossy", "cansi", "roff", @@ -157,10 +167,10 @@ dependencies = [ [[package]] name = "anstyle-svg" -version = "0.1.3" +version = "0.1.4" dependencies = [ - "anstream 0.6.13", - "anstyle 1.0.6", + "anstream 0.6.14", + "anstyle 1.0.7", "anstyle-lossy", "html-escape", "snapbox", @@ -169,58 +179,68 @@ dependencies = [ [[package]] name = "anstyle-syntect" -version = "1.0.0" +version = "1.0.1" dependencies = [ - "anstyle 1.0.6", + "anstyle 1.0.7", "syntect", ] [[package]] name = "anstyle-termcolor" -version = "1.1.0" +version = "1.1.1" dependencies = [ - "anstyle 1.0.6", + "anstyle 1.0.7", "termcolor", ] [[package]] name = "anstyle-wincon" -version = "3.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0699d10d2f4d628a98ee7b57b289abbc98ff3bad977cb3152709d4bf2330628" +checksum = "c677ab05e09154296dd37acecd46420c17b9713e8366facafa8fc0885167cf4c" dependencies = [ - "anstyle 1.0.0", + "anstyle 1.0.2", "windows-sys 0.48.0", ] [[package]] name = "anstyle-wincon" version = "3.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7" +dependencies = [ + "anstyle 1.0.2", + "windows-sys 0.52.0", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.3" dependencies = [ - "anstyle 1.0.6", + "anstyle 1.0.7", "lexopt", "windows-sys 0.52.0", ] [[package]] name = "anstyle-yansi" -version = "1.0.0" +version = "1.0.1" dependencies = [ - "anstyle 1.0.6", + "anstyle 1.0.7", "yansi", ] [[package]] name = "arrayvec" -version = "0.7.2" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6" +checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" [[package]] name = "autocfg" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" [[package]] name = "bit-set" @@ -245,15 +265,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" - -[[package]] -name = "bumpalo" -version = "3.12.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d261e256854913907f67ed06efbc3338dfe6179796deefc1ff763fc1aee5535" +checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" [[package]] name = "cansi" @@ -261,69 +275,31 @@ version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4bdcae87153686017415ce77e48c53e6818a0a058f0e21b56640d1e944967ef8" -[[package]] -name = "cast" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" - -[[package]] -name = "cc" -version = "1.0.79" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" - [[package]] name = "cfg-if" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" -[[package]] -name = "ciborium" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0c137568cc60b904a7724001b35ce2630fd00d5d84805fbb608ab89509d788f" -dependencies = [ - "ciborium-io", - "ciborium-ll", - "serde", -] - -[[package]] -name = "ciborium-io" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "346de753af073cc87b52b2083a506b38ac176a44cfb05497b622e27be899b369" - -[[package]] -name = "ciborium-ll" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "213030a2b5a4e0c0892b6652260cf6ccac84827b83a85a534e178e3906c4cf1b" -dependencies = [ - "ciborium-io", - "half", -] - [[package]] name = "clap" -version = "4.4.18" +version = "4.3.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e578d6ec4194633722ccf9544794b71b1385c3c027efe0c55db226fc880865c" +checksum = "fb690e81c7840c0d7aade59f242ea3b41b9bc27bcd5997890e7702ae4b32e487" dependencies = [ "clap_builder", "clap_derive", + "once_cell", ] [[package]] name = "clap_builder" -version = "4.4.18" +version = "4.3.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4df4df40ec50c46000231c914968278b1eb05098cf8f1b3a518a95030e71d1c7" +checksum = "5ed2e96bc16d8d740f6f48d663eddf4b8a0983e79210fd55479b7bcd0a69860e" dependencies = [ - "anstream 0.6.11", - "anstyle 1.0.0", + "anstream 0.3.2", + "anstyle 1.0.2", "clap_lex", "strsim", "terminal_size", @@ -331,21 +307,21 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.4.7" +version = "4.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf9804afaaf59a91e75b022a30fb7229a7901f60c755489cc61c9b423b836442" +checksum = "54a9bb5758fc5dfe728d1019941681eccaf0cf8a4189b692a0ee2f2ecf90a050" dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.60", ] [[package]] name = "clap_lex" -version = "0.6.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1" +checksum = "2da6da31387c7e4ef160ffab6d5e7f00c42626fe39aea70a7b0f1773f7dd6c1b" [[package]] name = "codegenrs" @@ -361,20 +337,20 @@ dependencies = [ [[package]] name = "colorchoice" version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" [[package]] name = "colorchoice" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" +version = "1.0.1" [[package]] name = "colorchoice-clap" -version = "1.0.3" +version = "1.0.4" dependencies = [ - "anstream 0.6.13", + "anstream 0.6.14", "clap", - "colorchoice 1.0.0", + "colorchoice 1.0.1", "owo-colors", ] @@ -399,92 +375,13 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" -[[package]] -name = "criterion" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2b12d017a929603d80db1831cd3a24082f8137ce19c69e6447f54f5fc8d692f" -dependencies = [ - "anes", - "cast", - "ciborium", - "clap", - "criterion-plot", - "is-terminal", - "itertools", - "num-traits", - "once_cell", - "oorandom", - "plotters", - "rayon", - "regex", - "serde", - "serde_derive", - "serde_json", - "tinytemplate", - "walkdir", -] - -[[package]] -name = "criterion-plot" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b50826342786a51a89e2da3a28f1c32b06e387201bc2d19791f622c673706b1" -dependencies = [ - "cast", - "itertools", -] - -[[package]] -name = "crossbeam-channel" -version = "0.5.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf2b3e8478797446514c91ef04bafcb59faba183e621ad488df88983cc14128c" -dependencies = [ - "cfg-if", - "crossbeam-utils", -] - -[[package]] -name = "crossbeam-deque" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce6fd6f855243022dcecf8702fef0c297d4338e226845fe067f6341ad9fa0cef" -dependencies = [ - "cfg-if", - "crossbeam-epoch", - "crossbeam-utils", -] - -[[package]] -name = "crossbeam-epoch" -version = "0.9.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46bd5f3f85273295a9d14aedfb86f6aadbff6d8f5295c4a9edb08e819dcf5695" -dependencies = [ - "autocfg", - "cfg-if", - "crossbeam-utils", - "memoffset", - "scopeguard", -] - -[[package]] -name = "crossbeam-utils" -version = "0.8.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c063cd8cc95f5c377ed0d4b49a4b21f632396ff690e8470c29b3359b346984b" -dependencies = [ - "cfg-if", -] - [[package]] name = "crossterm" version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f476fe445d41c9e991fd07515a6f463074b782242ccf4a5b7b1d1012e70824df" dependencies = [ - "bitflags 2.4.0", + "bitflags 2.5.0", "crossterm_winapi", "libc", "parking_lot", @@ -510,7 +407,7 @@ dependencies = [ "proc-macro2", "quote", "rustc_version", - "syn 1.0.102", + "syn 1.0.109", ] [[package]] @@ -521,9 +418,9 @@ checksum = "524cbf6897b527295dff137cec09ecf3a05f4fddffd7dfcd1585403449e74198" [[package]] name = "divan" -version = "0.1.11" +version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5398159ee27f2b123d89b856bad61725442f37df5fb98c30cd570c318d594aee" +checksum = "a0d567df2c9c2870a43f3f2bd65aaeb18dbce1c18f217c3e564b4fbaeb3ee56c" dependencies = [ "cfg-if", "clap", @@ -535,78 +432,47 @@ dependencies = [ [[package]] name = "divan-macros" -version = "0.1.11" +version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5092f66eb3563a01e85552731ae82c04c934ff4efd7ad1a0deae7b948f4b3ec4" +checksum = "27540baf49be0d484d8f0130d7d8da3011c32a44d4fc873368154f1510e574a2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.60", ] [[package]] name = "dunce" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bd4b30a6560bbd9b4620f4de34c3f14f60848e58a9b7216801afcb4c7b31c3c" - -[[package]] -name = "either" -version = "1.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" - -[[package]] -name = "errno" -version = "0.2.8" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f639046355ee4f37944e44f60642c6f3a7efa3cf6b78c78a0d989a8ce6c396a1" -dependencies = [ - "errno-dragonfly", - "libc", - "winapi", -] +checksum = "56ce8c6da7551ec6c462cbaf3bfbc75131ebbfa1c944aeaa9dab51ca1c5f0c3b" [[package]] name = "errno" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "136526188508e25c6fef639d7927dfb3e0e3084488bf202267829cf7fc23dbdd" -dependencies = [ - "errno-dragonfly", - "libc", - "windows-sys 0.48.0", -] - -[[package]] -name = "errno-dragonfly" -version = "0.1.2" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" +checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" dependencies = [ - "cc", "libc", + "windows-sys 0.52.0", ] [[package]] name = "fastrand" -version = "1.9.0" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be" -dependencies = [ - "instant", -] +checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a" [[package]] name = "filetime" -version = "0.2.20" +version = "0.2.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a3de6e8d11b22ff9edc6d916f890800597d60f8b2da1caf2955c274638d6412" +checksum = "1ee447700ac8aa0b2f2bd7bc4462ad686ba06baa6727ac149a2d6277f0d240fd" dependencies = [ "cfg-if", "libc", - "redox_syscall", - "windows-sys 0.45.0", + "redox_syscall 0.4.1", + "windows-sys 0.52.0", ] [[package]] @@ -617,21 +483,15 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "getrandom" -version = "0.2.8" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" +checksum = "94b22e06ecb0110981051723910cbf0b5f5e09a2062dd7663334ee79a9d1286c" dependencies = [ "cfg-if", "libc", "wasi", ] -[[package]] -name = "half" -version = "1.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7" - [[package]] name = "heck" version = "0.4.1" @@ -640,18 +500,9 @@ checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" [[package]] name = "hermit-abi" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" -dependencies = [ - "libc", -] - -[[package]] -name = "hermit-abi" -version = "0.3.1" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" +checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" [[package]] name = "html-escape" @@ -662,59 +513,42 @@ dependencies = [ "utf8-width", ] -[[package]] -name = "instant" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" -dependencies = [ - "cfg-if", -] - [[package]] name = "io-lifetimes" -version = "1.0.5" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1abeb7a0dd0f8181267ff8adc397075586500b81b28a73e8a0208b00fc170fb3" +checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" dependencies = [ + "hermit-abi", "libc", - "windows-sys 0.45.0", + "windows-sys 0.48.0", ] [[package]] name = "is-terminal" -version = "0.4.9" +version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" +checksum = "f23ff5ef2b80d608d61efee834934d862cd92461afc0560dedf493e4c033738b" dependencies = [ - "hermit-abi 0.3.1", - "rustix 0.38.11", - "windows-sys 0.48.0", + "hermit-abi", + "libc", + "windows-sys 0.52.0", ] [[package]] -name = "itertools" -version = "0.10.5" +name = "is_terminal_polyfill" +version = "1.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" +checksum = "b52b2de84ed0341893ce61ca1af04fa54eea0a764ecc38c6855cc5db84dc1927" dependencies = [ - "either", + "is-terminal", ] [[package]] name = "itoa" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4217ad341ebadf8d8e724e264f13e593e0648f5b3e94b3896a5df283be015ecc" - -[[package]] -name = "js-sys" -version = "0.3.61" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "445dde2150c55e483f3d8416706b97ec8e8237c307e5b7b4b8dd15e6af2a0730" -dependencies = [ - "wasm-bindgen", -] +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] name = "lazy_static" @@ -730,61 +564,43 @@ checksum = "baff4b617f7df3d896f97fe922b64817f6cd9a756bb81d40f8883f2f66dcb401" [[package]] name = "libc" -version = "0.2.153" +version = "0.2.154" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" +checksum = "ae743338b92ff9146ce83992f766a31066a91a8c84a45e0e9f21e7cf6de6d346" [[package]] name = "libm" -version = "0.2.6" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "348108ab3fba42ec82ff6e9564fc4ca0247bdccdc68dd8af9764bbc79c3c8ffb" +checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" [[package]] name = "linux-raw-sys" -version = "0.1.4" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4" +checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" [[package]] name = "linux-raw-sys" -version = "0.4.5" +version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57bcfdad1b858c2db7c38303a6d2ad4dfaf5eb53dfeb0910128b2c26d6158503" +checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" [[package]] name = "lock_api" -version = "0.4.9" +version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df" +checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" dependencies = [ "autocfg", "scopeguard", ] -[[package]] -name = "log" -version = "0.4.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" -dependencies = [ - "cfg-if", -] - [[package]] name = "memchr" -version = "2.5.0" +version = "2.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" - -[[package]] -name = "memoffset" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d61c719bcfbcf5d62b3a09efa6088de8c54bc0bfcd3ea7ae39fcc186108b8de1" -dependencies = [ - "autocfg", -] +checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" [[package]] name = "normalize-line-endings" @@ -794,35 +610,19 @@ checksum = "61807f77802ff30975e01f4f071c8ba10c022052f98b3294119f3e615d13e5be" [[package]] name = "num-traits" -version = "0.2.15" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" +checksum = "da0df0e5185db44f69b44f26786fe401b6c293d1907744beaa7fa62b2e5a517a" dependencies = [ "autocfg", "libm", ] -[[package]] -name = "num_cpus" -version = "1.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b" -dependencies = [ - "hermit-abi 0.2.6", - "libc", -] - [[package]] name = "once_cell" -version = "1.15.0" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e82dad04139b71a90c080c8463fe0dc7902db5192d939bd0950f074d014339e1" - -[[package]] -name = "oorandom" -version = "11.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "owo-colors" @@ -832,9 +632,9 @@ checksum = "caff54706df99d2a78a5a4e3455ff45448d81ef1bb63c22cd14052ca0e993a3f" [[package]] name = "parking_lot" -version = "0.12.1" +version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" +checksum = "7e4af0ca4f6caed20e900d564c242b8e5d4903fdacf31d3daf527b66fe6f42fb" dependencies = [ "lock_api", "parking_lot_core", @@ -842,43 +642,15 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.3" +version = "0.9.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09a279cbf25cb0757810394fbc1e359949b59e348145c643a939a525692e6929" +checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" dependencies = [ "cfg-if", "libc", - "redox_syscall", + "redox_syscall 0.5.1", "smallvec", - "windows-sys 0.36.1", -] - -[[package]] -name = "plotters" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2538b639e642295546c50fcd545198c9d64ee2a38620a628724a3b266d5fbf97" -dependencies = [ - "num-traits", - "plotters-backend", - "plotters-svg", - "wasm-bindgen", - "web-sys", -] - -[[package]] -name = "plotters-backend" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "193228616381fecdc1224c62e96946dfbc73ff4384fba576e052ff8c1bea8142" - -[[package]] -name = "plotters-svg" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9a81d2759aae1dae668f783c308bc5c8ebd191ff4184aaa1b37f65a6ae5a56f" -dependencies = [ - "plotters-backend", + "windows-targets 0.52.5", ] [[package]] @@ -889,9 +661,9 @@ checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "proc-macro2" -version = "1.0.78" +version = "1.0.81" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" +checksum = "3d1597b0c024618f09a9c3b8655b7e430397a36d23fdafec26d6965e9eec3eba" dependencies = [ "unicode-ident", ] @@ -904,13 +676,13 @@ checksum = "31b476131c3c86cb68032fdc5cb6d5a1045e3e42d96b69fa599fd77701e1f5bf" dependencies = [ "bit-set", "bit-vec", - "bitflags 2.4.0", + "bitflags 2.5.0", "lazy_static", "num-traits", "rand", "rand_chacha", "rand_xorshift", - "regex-syntax 0.8.2", + "regex-syntax", "rusty-fork", "tempfile", "unarray", @@ -924,9 +696,9 @@ checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" [[package]] name = "quote" -version = "1.0.35" +version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" dependencies = [ "proc-macro2", ] @@ -970,44 +742,22 @@ dependencies = [ "rand_core", ] -[[package]] -name = "rayon" -version = "1.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6db3a213adf02b3bcfd2d3846bb41cb22857d131789e01df434fb7e7bc0759b7" -dependencies = [ - "either", - "rayon-core", -] - -[[package]] -name = "rayon-core" -version = "1.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "356a0625f1954f730c0201cdab48611198dc6ce21f4acff55089b5a78e6e835b" -dependencies = [ - "crossbeam-channel", - "crossbeam-deque", - "crossbeam-utils", - "num_cpus", -] - [[package]] name = "redox_syscall" -version = "0.2.16" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" +checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" dependencies = [ "bitflags 1.3.2", ] [[package]] -name = "regex" -version = "1.7.1" +name = "redox_syscall" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48aaa5748ba571fb95cd2c85c09f629215d3a6ece942baa100950af03a34f733" +checksum = "469052894dcb553421e483e4209ee581a45100d31b4018de03e5a7ad86374a7e" dependencies = [ - "regex-syntax 0.6.28", + "bitflags 2.5.0", ] [[package]] @@ -1018,15 +768,9 @@ checksum = "30b661b2f27137bdbc16f00eda72866a92bb28af1753ffbd56744fb6e2e9cd8e" [[package]] name = "regex-syntax" -version = "0.6.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" - -[[package]] -name = "regex-syntax" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" +checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56" [[package]] name = "roff" @@ -1045,29 +789,29 @@ dependencies = [ [[package]] name = "rustix" -version = "0.36.8" +version = "0.37.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f43abb88211988493c1abb44a70efa56ff0ce98f233b7b276146f1f3f7ba9644" +checksum = "fea8ca367a3a01fe35e6943c400addf443c0f57670e6ec51196f71a4b8762dd2" dependencies = [ "bitflags 1.3.2", - "errno 0.2.8", + "errno", "io-lifetimes", "libc", - "linux-raw-sys 0.1.4", - "windows-sys 0.45.0", + "linux-raw-sys 0.3.8", + "windows-sys 0.48.0", ] [[package]] name = "rustix" -version = "0.38.11" +version = "0.38.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0c3dde1fc030af041adc40e79c0e7fbcf431dd24870053d187d7c66e4b87453" +checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" dependencies = [ - "bitflags 2.4.0", - "errno 0.3.3", + "bitflags 2.5.0", + "errno", "libc", - "linux-raw-sys 0.4.5", - "windows-sys 0.48.0", + "linux-raw-sys 0.4.13", + "windows-sys 0.52.0", ] [[package]] @@ -1084,9 +828,9 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.11" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4501abdff3ae82a1c1b477a17252eb69cee9e66eb915c1abaa4f44d873df9f09" +checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1" [[package]] name = "same-file" @@ -1099,41 +843,41 @@ dependencies = [ [[package]] name = "scopeguard" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "semver" -version = "1.0.16" +version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58bc9567378fc7690d6b2addae4e60ac2eeea07becb2c64b9f218b53865cba2a" +checksum = "92d43fe69e652f3df9bdc2b85b2854a0825b86e4fb76bc44d945137d053639ca" [[package]] name = "serde" -version = "1.0.145" +version = "1.0.200" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "728eb6351430bccb993660dfffc5a72f91ccc1295abaa8ce19b27ebe4f75568b" +checksum = "ddc6f9cc94d67c0e21aaf7eda3a010fd3af78ebf6e096aa6e2e13c79749cce4f" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.145" +version = "1.0.200" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81fa1584d3d1bcacd84c277a0dfe21f5b0f6accf4a23d04d4c6d61f1af522b4c" +checksum = "856f046b9400cee3c8c94ed572ecdb752444c24528c035cd35882aad6f492bcb" dependencies = [ "proc-macro2", "quote", - "syn 1.0.102", + "syn 2.0.60", ] [[package]] name = "serde_json" -version = "1.0.86" +version = "1.0.116" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41feea4228a6f1cd09ec7a3593a682276702cd67b5273544757dae23c096f074" +checksum = "3e17db7126d17feb94eb3fad46bf1a96b034e8aacbc2e775fe81505f8b0b2813" dependencies = [ "itoa", "ryu", @@ -1142,24 +886,24 @@ dependencies = [ [[package]] name = "similar" -version = "2.2.1" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "420acb44afdae038210c99e69aae24109f32f15500aa708e81d46c9f29d55fcf" +checksum = "fa42c91313f1d05da9b26f267f931cf178d4aba455b4c4622dd7355eb80c6640" [[package]] name = "smallvec" -version = "1.9.0" +version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fd0db749597d91ff862fd1d55ea87f7855a744a8425a64695b6fca237d1dad1" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" [[package]] name = "snapbox" -version = "0.5.1" +version = "0.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47d9a121ed3297bc4575fa774033a9f1084e0a0c8de8dff416df4eae834121b3" +checksum = "8ac441e1ecf678f68423d47f376d53fabce1afba92c8f68e31508eb27df8562a" dependencies = [ - "anstream 0.6.11", - "anstyle 1.0.0", + "anstream 0.6.13", + "anstyle 1.0.2", "content_inspector", "dunce", "filetime", @@ -1176,7 +920,7 @@ version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e1c4b838b05d15ab22754068cb73500b2f3b07bf09d310e15b27f88160f1de40" dependencies = [ - "anstream 0.6.11", + "anstream 0.6.13", ] [[package]] @@ -1196,9 +940,9 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "syn" -version = "1.0.102" +version = "1.0.109" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fcd952facd492f9be3ef0d0b7032a6e442ee9b361d4acc2b1d0c4aaa5f613a1" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" dependencies = [ "proc-macro2", "quote", @@ -1207,9 +951,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.48" +version = "2.0.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" +checksum = "909518bc7b1c9b779f1bbf07f2929d35af9f0f37e47c6e9ef7f9dddc1e1821f3" dependencies = [ "proc-macro2", "quote", @@ -1218,12 +962,11 @@ dependencies = [ [[package]] name = "syntect" -version = "5.0.0" +version = "5.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6c454c27d9d7d9a84c7803aaa3c50cd088d2906fe3c6e42da3209aa623576a8" +checksum = "874dcfa363995604333cf947ae9f751ca3af4522c60886774c4963943b4746b1" dependencies = [ "bitflags 1.3.2", - "lazy_static", "once_cell", "serde", "serde_derive", @@ -1234,64 +977,53 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.4.0" +version = "3.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af18f7ae1acd354b992402e9ec5864359d693cd8a79dcbef59f76891701c1e95" +checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" dependencies = [ "cfg-if", "fastrand", - "redox_syscall", - "rustix 0.36.8", - "windows-sys 0.42.0", + "rustix 0.38.34", + "windows-sys 0.52.0", ] [[package]] name = "termcolor" -version = "1.2.0" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6" +checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" dependencies = [ "winapi-util", ] [[package]] name = "terminal_size" -version = "0.3.0" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21bebf2b7c9e0a515f6e0f8c51dc0f8e4696391e6f1ff30379559f8365fb0df7" +checksum = "8e6bf6f19e9f8ed8d4048dc22981458ebcf406d67e94cd422e5ecd73d63b3237" dependencies = [ - "rustix 0.38.11", + "rustix 0.37.27", "windows-sys 0.48.0", ] [[package]] name = "thiserror" -version = "1.0.37" +version = "1.0.59" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10deb33631e3c9018b9baf9dcbbc4f737320d2b576bac10f6aefa048fa407e3e" +checksum = "f0126ad08bff79f29fc3ae6a55cc72352056dfff61e3ff8bb7129476d44b23aa" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.37" +version = "1.0.59" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "982d17546b47146b28f7c22e3d08465f6b8903d0ea13c1660d9d84a6e7adcdbb" +checksum = "d1cd413b5d558b4c5bf3680e324a6fa5014e7b7c067a51e69dbdf47eb7148b66" dependencies = [ "proc-macro2", "quote", - "syn 1.0.102", -] - -[[package]] -name = "tinytemplate" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be4d6b5f19ff7664e8c98d03e2139cb510db9b0a60b55f8e8709b689d939b6bc" -dependencies = [ - "serde", - "serde_json", + "syn 2.0.60", ] [[package]] @@ -1302,15 +1034,15 @@ checksum = "eaea85b334db583fe3274d12b4cd1880032beab409c0d774be044d4480ab9a94" [[package]] name = "unicode-ident" -version = "1.0.5" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ceab39d59e4c9499d4e5a8ee0e2735b891bb7308ac83dfb4e80cad195c9f6f3" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "unicode-width" -version = "0.1.11" +version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" +checksum = "68f5e5f3158ecfd4b8ff6fe086db7c8467a2dfdac97fe420f2b7c4aa97af66d6" [[package]] name = "utf8-width" @@ -1355,12 +1087,11 @@ dependencies = [ [[package]] name = "walkdir" -version = "2.3.2" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56" +checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" dependencies = [ "same-file", - "winapi", "winapi-util", ] @@ -1370,70 +1101,6 @@ version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" -[[package]] -name = "wasm-bindgen" -version = "0.2.84" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31f8dcbc21f30d9b8f2ea926ecb58f6b91192c17e9d33594b3df58b2007ca53b" -dependencies = [ - "cfg-if", - "wasm-bindgen-macro", -] - -[[package]] -name = "wasm-bindgen-backend" -version = "0.2.84" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95ce90fd5bcc06af55a641a86428ee4229e44e07033963a2290a8e241607ccb9" -dependencies = [ - "bumpalo", - "log", - "once_cell", - "proc-macro2", - "quote", - "syn 1.0.102", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-macro" -version = "0.2.84" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c21f77c0bedc37fd5dc21f897894a5ca01e7bb159884559461862ae90c0b4c5" -dependencies = [ - "quote", - "wasm-bindgen-macro-support", -] - -[[package]] -name = "wasm-bindgen-macro-support" -version = "0.2.84" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2aff81306fcac3c7515ad4e177f521b5c9a15f2b08f4e32d823066102f35a5f6" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.102", - "wasm-bindgen-backend", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-shared" -version = "0.2.84" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0046fef7e28c3804e5e38bfa31ea2a0f73905319b677e57ebe37e49358989b5d" - -[[package]] -name = "web-sys" -version = "0.3.61" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e33b99f4b23ba3eec1a53ac264e35a755f00e966e0065077d6027c0f575b0b97" -dependencies = [ - "js-sys", - "wasm-bindgen", -] - [[package]] name = "winapi" version = "0.3.9" @@ -1452,11 +1119,11 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" -version = "0.1.5" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +checksum = "4d4cc384e1e73b93bafa6fb4f1df8c41695c8a91cf9c4c64358067d15a7b6c6b" dependencies = [ - "winapi", + "windows-sys 0.52.0", ] [[package]] @@ -1465,50 +1132,13 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" -[[package]] -name = "windows-sys" -version = "0.36.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea04155a16a59f9eab786fe12a4a450e75cdb175f9e0d80da1e17db09f55b8d2" -dependencies = [ - "windows_aarch64_msvc 0.36.1", - "windows_i686_gnu 0.36.1", - "windows_i686_msvc 0.36.1", - "windows_x86_64_gnu 0.36.1", - "windows_x86_64_msvc 0.36.1", -] - -[[package]] -name = "windows-sys" -version = "0.42.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" -dependencies = [ - "windows_aarch64_gnullvm 0.42.1", - "windows_aarch64_msvc 0.42.1", - "windows_i686_gnu 0.42.1", - "windows_i686_msvc 0.42.1", - "windows_x86_64_gnu 0.42.1", - "windows_x86_64_gnullvm 0.42.1", - "windows_x86_64_msvc 0.42.1", -] - -[[package]] -name = "windows-sys" -version = "0.45.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" -dependencies = [ - "windows-targets 0.42.1", -] - [[package]] name = "windows-sys" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ - "windows-targets 0.48.0", + "windows-targets 0.48.5", ] [[package]] @@ -1517,209 +1147,129 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets 0.52.0", + "windows-targets 0.52.5", ] [[package]] name = "windows-targets" -version = "0.42.1" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e2522491fbfcd58cc84d47aeb2958948c4b8982e9a2d8a2a35bbaed431390e7" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" dependencies = [ - "windows_aarch64_gnullvm 0.42.1", - "windows_aarch64_msvc 0.42.1", - "windows_i686_gnu 0.42.1", - "windows_i686_msvc 0.42.1", - "windows_x86_64_gnu 0.42.1", - "windows_x86_64_gnullvm 0.42.1", - "windows_x86_64_msvc 0.42.1", + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", ] [[package]] name = "windows-targets" -version = "0.48.0" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5" +checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" dependencies = [ - "windows_aarch64_gnullvm 0.48.0", - "windows_aarch64_msvc 0.48.0", - "windows_i686_gnu 0.48.0", - "windows_i686_msvc 0.48.0", - "windows_x86_64_gnu 0.48.0", - "windows_x86_64_gnullvm 0.48.0", - "windows_x86_64_msvc 0.48.0", + "windows_aarch64_gnullvm 0.52.5", + "windows_aarch64_msvc 0.52.5", + "windows_i686_gnu 0.52.5", + "windows_i686_gnullvm", + "windows_i686_msvc 0.52.5", + "windows_x86_64_gnu 0.52.5", + "windows_x86_64_gnullvm 0.52.5", + "windows_x86_64_msvc 0.52.5", ] -[[package]] -name = "windows-targets" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" -dependencies = [ - "windows_aarch64_gnullvm 0.52.0", - "windows_aarch64_msvc 0.52.0", - "windows_i686_gnu 0.52.0", - "windows_i686_msvc 0.52.0", - "windows_x86_64_gnu 0.52.0", - "windows_x86_64_gnullvm 0.52.0", - "windows_x86_64_msvc 0.52.0", -] - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.42.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c9864e83243fdec7fc9c5444389dcbbfd258f745e7853198f365e3c4968a608" - [[package]] name = "windows_aarch64_gnullvm" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.0" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" +checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" [[package]] name = "windows_aarch64_msvc" -version = "0.36.1" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_aarch64_msvc" -version = "0.42.1" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c8b1b673ffc16c47a9ff48570a9d85e25d265735c503681332589af6253c6c7" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" +checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" [[package]] name = "windows_i686_gnu" -version = "0.36.1" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_gnu" -version = "0.42.1" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de3887528ad530ba7bdbb1faa8275ec7a1155a45ffa57c37993960277145d640" +checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" [[package]] -name = "windows_i686_gnu" -version = "0.48.0" +name = "windows_i686_gnullvm" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" - -[[package]] -name = "windows_i686_gnu" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" - -[[package]] -name = "windows_i686_msvc" -version = "0.36.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024" - -[[package]] -name = "windows_i686_msvc" -version = "0.42.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf4d1122317eddd6ff351aa852118a2418ad4214e6613a50e0191f7004372605" +checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" [[package]] name = "windows_i686_msvc" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_i686_msvc" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.36.1" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1" +checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" [[package]] name = "windows_x86_64_gnu" -version = "0.42.1" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1040f221285e17ebccbc2591ffdc2d44ee1f9186324dd3e84e99ac68d699c45" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnu" -version = "0.48.0" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" +checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" [[package]] name = "windows_x86_64_gnullvm" -version = "0.42.1" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "628bfdf232daa22b0d64fdb62b09fcc36bb01f05a3939e20ab73aaf9470d0463" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_gnullvm" -version = "0.48.0" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.36.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680" +checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" [[package]] name = "windows_x86_64_msvc" -version = "0.42.1" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "447660ad36a13288b1db4d4248e857b510e8c3a225c822ba4fb748c0aafecffd" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "windows_x86_64_msvc" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.52.0" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" +checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" [[package]] name = "yansi" diff --git a/Cargo.toml b/Cargo.toml index e0e9b920..6e3e618e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,7 @@ resolver = "2" [workspace.package] license = "MIT OR Apache-2.0" edition = "2021" -rust-version = "1.70.0" # MSRV +rust-version = "1.65.0" # MSRV include = [ "build.rs", "src/**/*", @@ -16,3 +16,73 @@ include = [ "benches/**/*", "examples/**/*" ] + +[workspace.lints.rust] +rust_2018_idioms = "warn" +unreachable_pub = "warn" +unsafe_op_in_unsafe_fn = "warn" +unused_lifetimes = "warn" +unused_macro_rules = "warn" +unused_qualifications = "warn" + +[workspace.lints.clippy] +bool_assert_comparison = "allow" +branches_sharing_code = "allow" +checked_conversions = "warn" +collapsible_else_if = "allow" +create_dir = "warn" +dbg_macro = "warn" +debug_assert_with_mut_call = "warn" +doc_markdown = "warn" +empty_enum = "warn" +enum_glob_use = "warn" +expl_impl_clone_on_copy = "warn" +explicit_deref_methods = "warn" +explicit_into_iter_loop = "warn" +fallible_impl_from = "warn" +filter_map_next = "warn" +flat_map_option = "warn" +float_cmp_const = "warn" +fn_params_excessive_bools = "warn" +from_iter_instead_of_collect = "warn" +if_same_then_else = "allow" +implicit_clone = "warn" +imprecise_flops = "warn" +inconsistent_struct_constructor = "warn" +inefficient_to_string = "warn" +infinite_loop = "warn" +invalid_upcast_comparisons = "warn" +items_after_statements = "warn" +large_digit_groups = "warn" +large_stack_arrays = "warn" +large_types_passed_by_value = "warn" +let_and_return = "allow" # sometimes good to name what you are returning +linkedlist = "warn" +lossy_float_literal = "warn" +macro_use_imports = "warn" +match_wildcard_for_single_variants = "warn" +mem_forget = "warn" +mutex_integer = "warn" +needless_continue = "warn" +needless_for_each = "warn" +negative_feature_names = "warn" +path_buf_push_overwrite = "warn" +ptr_as_ptr = "warn" +rc_mutex = "warn" +redundant_feature_names = "warn" +ref_option_ref = "warn" +rest_pat_in_fully_bound_structs = "warn" +same_functions_in_if_condition = "warn" +self_named_module_files = "warn" +semicolon_if_nothing_returned = "warn" +single_match_else = "warn" +str_to_string = "warn" +string_add = "warn" +string_add_assign = "warn" +string_lit_as_bytes = "warn" +string_to_string = "warn" +todo = "warn" +trait_duplication_in_bounds = "warn" +verbose_file_reads = "warn" +wildcard_imports = "warn" +zero_sized_map_values = "warn" diff --git a/README.md b/README.md index dceaac1d..f86d6f62 100644 --- a/README.md +++ b/README.md @@ -6,13 +6,16 @@ This repo contains: - [`anstyle-ls`](./crates/anstyle-ls) for parsing `LS_COLORS` style descriptions - Convert to other formats - [`anstyle-roff`](./crates/anstyle-roff) for converting ANSI codes to `ROFF` + - [`anstyle-svg`](./crates/anstyle-svg) for converting ANSI codes to `SVG` - Styling integration - [`anstyle-ansi-term`](./crates/anstyle-ansi-term) for adapting `anstyle` to `ansi_term` - [`anstyle-crossterm`](./crates/anstyle-crossterm) for adapting `anstyle` to `crossterm` - [`anstyle-owo-colors`](./crates/anstyle-owo-colors) for adapting `anstyle` to `owo-colors` + - [`anstyle-syntect`](./crates/anstyle-syntect) for adapting `anstyle` to `syntect` - [`anstyle-termcolor`](./crates/anstyle-termcolor) for adapting `anstyle` to `termcolor` - [`anstyle-yansi`](./crates/anstyle-yansi) for adapting `anstyle` to `yansi` - Utilities - [`anstyle-lossy`](./crates/anstyle-lossy) for converting between color types - [`anstyle-parse`](./crates/anstyle-parse) for parsing ANSI Style Escapes - [`anstyle-wincon`](./crates/anstyle-wincon) for styling legacy Microsoft terminals + - [`colorchoice-clap`](./crates/colorchoice-clap) for using `color` flag in `clap` diff --git a/crates/anstream/CHANGELOG.md b/crates/anstream/CHANGELOG.md index 4c81e057..5dbb0e49 100644 --- a/crates/anstream/CHANGELOG.md +++ b/crates/anstream/CHANGELOG.md @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] - ReleaseDate +## [0.6.14] - 2024-05-02 + +### Fixes + +- Drop MSRV to 1.65 + ## [0.6.13] - 2024-02-27 ### Fixes @@ -227,7 +233,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [0.0.1] - 2023-03-07 -[Unreleased]: https://github.com/rust-cli/anstyle/compare/anstream-v0.6.13...HEAD +[Unreleased]: https://github.com/rust-cli/anstyle/compare/anstream-v0.6.14...HEAD +[0.6.14]: https://github.com/rust-cli/anstyle/compare/anstream-v0.6.13...anstream-v0.6.14 [0.6.13]: https://github.com/rust-cli/anstyle/compare/anstream-v0.6.12...anstream-v0.6.13 [0.6.12]: https://github.com/rust-cli/anstyle/compare/anstream-v0.6.11...anstream-v0.6.12 [0.6.11]: https://github.com/rust-cli/anstyle/compare/anstream-v0.6.10...anstream-v0.6.11 diff --git a/crates/anstream/Cargo.toml b/crates/anstream/Cargo.toml index d40d2238..17a80e7d 100644 --- a/crates/anstream/Cargo.toml +++ b/crates/anstream/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "anstream" -version = "0.6.13" +version = "0.6.14" description = "A simple cross platform library for writing colored text to a terminal." repository = "https://github.com/rust-cli/anstyle.git" homepage = "https://github.com/rust-cli/anstyle" @@ -12,8 +12,8 @@ rust-version.workspace = true include.workspace = true [package.metadata.docs.rs] +all-features = true rustdoc-args = ["--cfg", "docsrs"] -cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"] [package.metadata.release] pre-release-replacements = [ @@ -37,17 +37,26 @@ anstyle-parse = { version = "0.2.0", path = "../anstyle-parse" } colorchoice = { version = "1.0.0", path = "../colorchoice" } anstyle-query = { version = "1.0.0", path = "../anstyle-query", optional = true } utf8parse = "0.2.1" +is_terminal_polyfill = "1.48" [target.'cfg(windows)'.dependencies] anstyle-wincon = { version = "3.0.1", path = "../anstyle-wincon", optional = true } [dev-dependencies] -criterion = "0.5.1" +divan = "0.1.11" lexopt = "0.3.0" owo-colors = "4.0.0" proptest = "1.4.0" strip-ansi-escapes = "0.2.0" +[[example]] +name = "dump-stream" +required-features = ["auto"] + +[[example]] +name = "query-stream" +required-features = ["auto"] + [[bench]] name = "strip" harness = false @@ -59,3 +68,6 @@ harness = false [[bench]] name = "stream" harness = false + +[lints] +workspace = true diff --git a/crates/anstream/benches/stream.rs b/crates/anstream/benches/stream.rs index f89aacf5..3d6203e9 100644 --- a/crates/anstream/benches/stream.rs +++ b/crates/anstream/benches/stream.rs @@ -1,81 +1,104 @@ +#![allow(clippy::unwrap_used)] + use std::io::Write as _; -use criterion::{black_box, Criterion}; - -fn stream(c: &mut Criterion) { - for (name, content) in [ - ("demo.vte", &include_bytes!("../tests/demo.vte")[..]), - ("rg_help.vte", &include_bytes!("../tests/rg_help.vte")[..]), - ("rg_linus.vte", &include_bytes!("../tests/rg_linus.vte")[..]), - ( - "state_changes", - &b"\x1b]2;X\x1b\\ \x1b[0m \x1bP0@\x1b\\"[..], - ), - ] { - let mut group = c.benchmark_group(name); - group.bench_function("nop", |b| { - b.iter(|| { - let buffer = Vec::with_capacity(content.len()); - let mut stream = buffer; - - stream.write_all(content).unwrap(); - - black_box(stream) - }) - }); - group.bench_function("StripStream", |b| { - b.iter(|| { - let buffer = Vec::with_capacity(content.len()); - let mut stream = anstream::StripStream::new(buffer); - - stream.write_all(content).unwrap(); - - black_box(stream) - }) - }); - #[cfg(all(windows, feature = "wincon"))] - group.bench_function("WinconStream", |b| { - b.iter(|| { - let buffer = Vec::with_capacity(content.len()); - let mut stream = anstream::WinconStream::new(buffer); - - stream.write_all(content).unwrap(); - - black_box(stream) - }) - }); - group.bench_function("AutoStream::always_ansi", |b| { - b.iter(|| { - let buffer = Vec::with_capacity(content.len()); - let mut stream = anstream::AutoStream::always_ansi(buffer); - - stream.write_all(content).unwrap(); - - black_box(stream) - }) - }); - group.bench_function("AutoStream::always", |b| { - b.iter(|| { - let buffer = Vec::with_capacity(content.len()); - let mut stream = anstream::AutoStream::always(buffer); - - stream.write_all(content).unwrap(); - - black_box(stream) - }) - }); - group.bench_function("AutoStream::never", |b| { - b.iter(|| { - let buffer = Vec::with_capacity(content.len()); - let mut stream = anstream::AutoStream::never(buffer); - - stream.write_all(content).unwrap(); - - black_box(stream) - }) - }); +#[divan::bench(args = DATA)] +fn nop(data: &Data) -> Vec { + let buffer = Vec::with_capacity(data.content().len()); + let mut stream = buffer; + + stream.write_all(data.content()).unwrap(); + + stream +} + +#[divan::bench(args = DATA)] +fn strip_stream(data: &Data) -> Vec { + let buffer = Vec::with_capacity(data.content().len()); + let mut stream = anstream::StripStream::new(buffer); + + stream.write_all(data.content()).unwrap(); + + stream.into_inner() +} + +#[divan::bench(args = DATA)] +#[cfg(all(windows, feature = "wincon"))] +fn wincon_stream(data: &Data) -> Vec { + let buffer = Vec::with_capacity(data.content().len()); + let mut stream = anstream::WinconStream::new(buffer); + + stream.write_all(data.content()).unwrap(); + + stream.into_inner() +} + +#[divan::bench(args = DATA)] +fn auto_stream_always_ansi(data: &Data) -> Vec { + let buffer = Vec::with_capacity(data.content().len()); + let mut stream = anstream::AutoStream::always_ansi(buffer); + + stream.write_all(data.content()).unwrap(); + + stream.into_inner() +} + +#[divan::bench(args = DATA)] +fn auto_stream_always(data: &Data) -> Vec { + let buffer = Vec::with_capacity(data.content().len()); + let mut stream = anstream::AutoStream::always(buffer); + + stream.write_all(data.content()).unwrap(); + + stream.into_inner() +} + +#[divan::bench(args = DATA)] +fn auto_stream_never(data: &Data) -> Vec { + let buffer = Vec::with_capacity(data.content().len()); + let mut stream = anstream::AutoStream::never(buffer); + + stream.write_all(data.content()).unwrap(); + + stream.into_inner() +} + +const DATA: &[Data] = &[ + Data( + "0-state_changes", + b"\x1b]2;X\x1b\\ \x1b[0m \x1bP0@\x1b\\".as_slice(), + ), + #[cfg(feature = "utf8")] + Data("1-demo.vte", include_bytes!("../tests/demo.vte").as_slice()), + Data( + "2-rg_help.vte", + include_bytes!("../tests/rg_help.vte").as_slice(), + ), + Data( + "3-rg_linus.vte", + include_bytes!("../tests/rg_linus.vte").as_slice(), + ), +]; + +#[derive(Debug)] +struct Data(&'static str, &'static [u8]); + +impl Data { + const fn name(&self) -> &'static str { + self.0 + } + + const fn content(&self) -> &'static [u8] { + self.1 } } -criterion::criterion_group!(benches, stream); -criterion::criterion_main!(benches); +impl std::fmt::Display for Data { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + self.name().fmt(f) + } +} + +fn main() { + divan::main(); +} diff --git a/crates/anstream/benches/strip.rs b/crates/anstream/benches/strip.rs index 9ed6178c..21ff89dd 100644 --- a/crates/anstream/benches/strip.rs +++ b/crates/anstream/benches/strip.rs @@ -1,4 +1,4 @@ -use criterion::{black_box, Criterion}; +#![allow(clippy::unwrap_used)] #[derive(Default)] struct Strip(String); @@ -19,18 +19,99 @@ impl anstyle_parse::Perform for Strip { } } -fn strip(c: &mut Criterion) { - for (name, content) in [ - ("demo.vte", &include_bytes!("../tests/demo.vte")[..]), - ("rg_help.vte", &include_bytes!("../tests/rg_help.vte")[..]), - ("rg_linus.vte", &include_bytes!("../tests/rg_linus.vte")[..]), - ( - "state_changes", - &b"\x1b]2;X\x1b\\ \x1b[0m \x1bP0@\x1b\\"[..], - ), - ] { +#[divan::bench(args = DATA)] +fn advance_strip(data: &Data) -> String { + let mut stripped = Strip::with_capacity(data.content().len()); + let mut parser = anstyle_parse::Parser::::new(); + + for byte in data.content() { + parser.advance(&mut stripped, *byte); + } + + stripped.0 +} + +#[divan::bench(args = DATA)] +fn strip_ansi_escapes(data: &Data) -> Vec { + let stripped = strip_ansi_escapes::strip(data.content()); + + stripped +} + +#[divan::bench(args = DATA)] +fn strip_str(data: &Data) -> String { + if let Ok(content) = std::str::from_utf8(data.content()) { + let stripped = anstream::adapter::strip_str(content).to_string(); + + stripped + } else { + "".to_owned() + } +} + +#[divan::bench(args = DATA)] +fn strip_str_strip_next(data: &Data) -> String { + if let Ok(content) = std::str::from_utf8(data.content()) { + let mut stripped = String::with_capacity(data.content().len()); + let mut state = anstream::adapter::StripStr::new(); + for printable in state.strip_next(content) { + stripped.push_str(printable); + } + + stripped + } else { + "".to_owned() + } +} + +#[divan::bench(args = DATA)] +fn strip_bytes(data: &Data) -> Vec { + let stripped = anstream::adapter::strip_bytes(data.content()).into_vec(); + + stripped +} + +const DATA: &[Data] = &[ + Data( + "0-state_changes", + b"\x1b]2;X\x1b\\ \x1b[0m \x1bP0@\x1b\\".as_slice(), + ), + #[cfg(feature = "utf8")] + Data("1-demo.vte", include_bytes!("../tests/demo.vte").as_slice()), + Data( + "2-rg_help.vte", + include_bytes!("../tests/rg_help.vte").as_slice(), + ), + Data( + "3-rg_linus.vte", + include_bytes!("../tests/rg_linus.vte").as_slice(), + ), +]; + +#[derive(Debug)] +struct Data(&'static str, &'static [u8]); + +impl Data { + const fn name(&self) -> &'static str { + self.0 + } + + const fn content(&self) -> &'static [u8] { + self.1 + } +} + +impl std::fmt::Display for Data { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + self.name().fmt(f) + } +} + +#[test] +fn verify_data() { + for data in DATA { // Make sure the comparison is fair - if let Ok(content) = std::str::from_utf8(content) { + if let Ok(content) = std::str::from_utf8(data.content()) { let mut stripped = Strip::with_capacity(content.len()); let mut parser = anstyle_parse::Parser::::new(); for byte in content.as_bytes() { @@ -46,57 +127,9 @@ fn strip(c: &mut Criterion) { .unwrap() ); } - - let mut group = c.benchmark_group(name); - group.bench_function("advance_strip", |b| { - b.iter(|| { - let mut stripped = Strip::with_capacity(content.len()); - let mut parser = - anstyle_parse::Parser::::new(); - - for byte in content { - parser.advance(&mut stripped, *byte); - } - - black_box(stripped.0) - }) - }); - group.bench_function("strip_ansi_escapes", |b| { - b.iter(|| { - let stripped = strip_ansi_escapes::strip(content); - - black_box(stripped) - }) - }); - if let Ok(content) = std::str::from_utf8(content) { - group.bench_function("strip_str", |b| { - b.iter(|| { - let stripped = anstream::adapter::strip_str(content).to_string(); - - black_box(stripped) - }) - }); - group.bench_function("StripStr", |b| { - b.iter(|| { - let mut stripped = String::with_capacity(content.len()); - let mut state = anstream::adapter::StripStr::new(); - for printable in state.strip_next(content) { - stripped.push_str(printable); - } - - black_box(stripped) - }) - }); - } - group.bench_function("strip_bytes", |b| { - b.iter(|| { - let stripped = anstream::adapter::strip_bytes(content).into_vec(); - - black_box(stripped) - }) - }); } } -criterion::criterion_group!(benches, strip); -criterion::criterion_main!(benches); +fn main() { + divan::main(); +} diff --git a/crates/anstream/benches/wincon.rs b/crates/anstream/benches/wincon.rs index 54e1f80a..707e8f81 100644 --- a/crates/anstream/benches/wincon.rs +++ b/crates/anstream/benches/wincon.rs @@ -1,26 +1,47 @@ -use criterion::{black_box, Criterion}; +#[divan::bench(args = DATA)] +fn nop(data: &Data) -> Vec<(anstyle::Style, String)> { + let mut state = anstream::adapter::WinconBytes::new(); + let stripped = state.extract_next(data.content()).collect::>(); -fn wincon(c: &mut Criterion) { - for (name, content) in [ - ("demo.vte", &include_bytes!("../tests/demo.vte")[..]), - ("rg_help.vte", &include_bytes!("../tests/rg_help.vte")[..]), - ("rg_linus.vte", &include_bytes!("../tests/rg_linus.vte")[..]), - ( - "state_changes", - &b"\x1b]2;X\x1b\\ \x1b[0m \x1bP0@\x1b\\"[..], - ), - ] { - let mut group = c.benchmark_group(name); - group.bench_function("wincon_bytes", |b| { - b.iter(|| { - let mut state = anstream::adapter::WinconBytes::new(); - let stripped = state.extract_next(content).collect::>(); + stripped +} + +const DATA: &[Data] = &[ + Data( + "0-state_changes", + b"\x1b]2;X\x1b\\ \x1b[0m \x1bP0@\x1b\\".as_slice(), + ), + #[cfg(feature = "utf8")] + Data("1-demo.vte", include_bytes!("../tests/demo.vte").as_slice()), + Data( + "2-rg_help.vte", + include_bytes!("../tests/rg_help.vte").as_slice(), + ), + Data( + "3-rg_linus.vte", + include_bytes!("../tests/rg_linus.vte").as_slice(), + ), +]; + +#[derive(Debug)] +struct Data(&'static str, &'static [u8]); + +impl Data { + const fn name(&self) -> &'static str { + self.0 + } - black_box(stripped) - }) - }); + const fn content(&self) -> &'static [u8] { + self.1 } } -criterion::criterion_group!(benches, wincon); -criterion::criterion_main!(benches); +impl std::fmt::Display for Data { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + self.name().fmt(f) + } +} + +fn main() { + divan::main(); +} diff --git a/crates/anstream/examples/dump-stream.rs b/crates/anstream/examples/dump-stream.rs index 8d80ce88..18bd2eb2 100644 --- a/crates/anstream/examples/dump-stream.rs +++ b/crates/anstream/examples/dump-stream.rs @@ -1,3 +1,5 @@ +//! Write colored text, adapting to the terminals capabilities + use std::io::Write; fn main() -> Result<(), lexopt::Error> { @@ -6,7 +8,9 @@ fn main() -> Result<(), lexopt::Error> { let mut stdout = stdout.lock(); for fixed in 0..16 { - let color = anstyle::Ansi256Color(fixed).into_ansi().unwrap(); + let color = anstyle::Ansi256Color(fixed) + .into_ansi() + .expect("within 4-bit color range"); let style = style(color, args.layer, args.effects); let _ = print_number(&mut stdout, fixed, style); if fixed == 7 || fixed == 15 { diff --git a/crates/anstream/examples/query-stream.rs b/crates/anstream/examples/query-stream.rs index fe0af95a..1c8670ec 100644 --- a/crates/anstream/examples/query-stream.rs +++ b/crates/anstream/examples/query-stream.rs @@ -1,3 +1,5 @@ +//! Report a terminal's capabilities + fn main() { println!("stdout:"); println!( diff --git a/crates/anstream/src/adapter/strip.rs b/crates/anstream/src/adapter/strip.rs index a8d67f80..fc0c1de8 100644 --- a/crates/anstream/src/adapter/strip.rs +++ b/crates/anstream/src/adapter/strip.rs @@ -145,11 +145,13 @@ fn next_str<'s>(bytes: &mut &'s [u8], state: &mut State) -> Option<&'s str> { #[inline] unsafe fn from_utf8_unchecked<'b>(bytes: &'b [u8], safety_justification: &'static str) -> &'b str { - if cfg!(debug_assertions) { - // Catch problems more quickly when testing - std::str::from_utf8(bytes).expect(safety_justification) - } else { - std::str::from_utf8_unchecked(bytes) + unsafe { + if cfg!(debug_assertions) { + // Catch problems more quickly when testing + std::str::from_utf8(bytes).expect(safety_justification) + } else { + std::str::from_utf8_unchecked(bytes) + } } } @@ -327,7 +329,7 @@ fn next_bytes<'s>( } #[derive(Default, Clone, Debug, PartialEq, Eq)] -pub struct Utf8Parser { +pub(crate) struct Utf8Parser { utf8_parser: utf8parse::Parser, } @@ -440,7 +442,7 @@ mod test { fn test_strip_byte_multibyte() { let bytes = [240, 145, 141, 139]; let expected = parser_strip(&bytes); - let actual = String::from_utf8(strip_byte(&bytes).to_vec()).unwrap(); + let actual = String::from_utf8(strip_byte(&bytes).clone()).unwrap(); assert_eq!(expected, actual); } @@ -456,7 +458,7 @@ mod test { fn test_strip_byte_del() { let bytes = [0x7f]; let expected = ""; - let actual = String::from_utf8(strip_byte(&bytes).to_vec()).unwrap(); + let actual = String::from_utf8(strip_byte(&bytes).clone()).unwrap(); assert_eq!(expected, actual); } @@ -502,7 +504,7 @@ mod test { dbg!(&s); dbg!(s.as_bytes()); let expected = parser_strip(s.as_bytes()); - let actual = String::from_utf8(strip_byte(s.as_bytes()).to_vec()).unwrap(); + let actual = String::from_utf8(strip_byte(s.as_bytes()).clone()).unwrap(); assert_eq!(expected, actual); } } diff --git a/crates/anstream/src/adapter/wincon.rs b/crates/anstream/src/adapter/wincon.rs index b0996838..f879e828 100644 --- a/crates/anstream/src/adapter/wincon.rs +++ b/crates/anstream/src/adapter/wincon.rs @@ -150,7 +150,7 @@ impl anstyle_parse::Perform for WinconCapture { break; } (State::Normal, 30..=37) => { - let color = to_ansi_color(value - 30).unwrap(); + let color = to_ansi_color(value - 30).expect("within 4-bit range"); style = style.fg_color(Some(color.into())); break; } @@ -163,7 +163,7 @@ impl anstyle_parse::Perform for WinconCapture { break; } (State::Normal, 40..=47) => { - let color = to_ansi_color(value - 40).unwrap(); + let color = to_ansi_color(value - 40).expect("within 4-bit range"); style = style.bg_color(Some(color.into())); break; } @@ -180,12 +180,16 @@ impl anstyle_parse::Perform for WinconCapture { state = State::PrepareCustomColor; } (State::Normal, 90..=97) => { - let color = to_ansi_color(value - 90).unwrap().bright(true); + let color = to_ansi_color(value - 90) + .expect("within 4-bit range") + .bright(true); style = style.fg_color(Some(color.into())); break; } (State::Normal, 100..=107) => { - let color = to_ansi_color(value - 100).unwrap().bright(true); + let color = to_ansi_color(value - 100) + .expect("within 4-bit range") + .bright(true); style = style.bg_color(Some(color.into())); break; } diff --git a/crates/anstream/src/auto.rs b/crates/anstream/src/auto.rs index ead08f77..743640f8 100644 --- a/crates/anstream/src/auto.rs +++ b/crates/anstream/src/auto.rs @@ -157,6 +157,7 @@ where } } + /// Returns `true` if the descriptor/handle refers to a terminal/tty. #[inline] pub fn is_terminal(&self) -> bool { match &self.inner { diff --git a/crates/anstream/src/lib.rs b/crates/anstream/src/lib.rs index 28febb3f..a496dae0 100644 --- a/crates/anstream/src/lib.rs +++ b/crates/anstream/src/lib.rs @@ -33,6 +33,9 @@ //! And this will correctly handle piping to a file, etc #![cfg_attr(docsrs, feature(doc_auto_cfg))] +#![warn(missing_docs)] +#![warn(clippy::print_stderr)] +#![warn(clippy::print_stdout)] pub mod adapter; pub mod stream; @@ -54,7 +57,9 @@ pub use wincon::WinconStream; #[allow(deprecated)] pub use buffer::Buffer; +/// An adaptive wrapper around the global standard output stream of the current process pub type Stdout = AutoStream; +/// An adaptive wrapper around the global standard error stream of the current process pub type Stderr = AutoStream; /// Create an ANSI escape code compatible stdout diff --git a/crates/anstream/src/stream.rs b/crates/anstream/src/stream.rs index e2f7e68d..b30d2323 100644 --- a/crates/anstream/src/stream.rs +++ b/crates/anstream/src/stream.rs @@ -41,21 +41,23 @@ impl RawStream for crate::Buffer {} #[allow(deprecated)] impl RawStream for &'_ mut crate::Buffer {} +/// Trait to determine if a descriptor/handle refers to a terminal/tty. pub trait IsTerminal: private::Sealed { + /// Returns `true` if the descriptor/handle refers to a terminal/tty. fn is_terminal(&self) -> bool; } impl IsTerminal for std::io::Stdout { #[inline] fn is_terminal(&self) -> bool { - std::io::IsTerminal::is_terminal(self) + is_terminal_polyfill::IsTerminal::is_terminal(self) } } impl IsTerminal for std::io::StdoutLock<'_> { #[inline] fn is_terminal(&self) -> bool { - std::io::IsTerminal::is_terminal(self) + is_terminal_polyfill::IsTerminal::is_terminal(self) } } @@ -69,14 +71,14 @@ impl IsTerminal for &'_ mut std::io::StdoutLock<'_> { impl IsTerminal for std::io::Stderr { #[inline] fn is_terminal(&self) -> bool { - std::io::IsTerminal::is_terminal(self) + is_terminal_polyfill::IsTerminal::is_terminal(self) } } impl IsTerminal for std::io::StderrLock<'_> { #[inline] fn is_terminal(&self) -> bool { - std::io::IsTerminal::is_terminal(self) + is_terminal_polyfill::IsTerminal::is_terminal(self) } } @@ -118,7 +120,7 @@ impl IsTerminal for &'_ mut Vec { impl IsTerminal for std::fs::File { #[inline] fn is_terminal(&self) -> bool { - std::io::IsTerminal::is_terminal(self) + is_terminal_polyfill::IsTerminal::is_terminal(self) } } @@ -145,11 +147,14 @@ impl IsTerminal for &'_ mut crate::Buffer { } } +/// Lock a stream pub trait AsLockedWrite: private::Sealed { + /// Locked writer type type Write<'w>: RawStream + 'w where Self: 'w; + /// Lock a stream fn as_locked_write(&mut self) -> Self::Write<'_>; } diff --git a/crates/anstream/src/strip.rs b/crates/anstream/src/strip.rs index 2d1168ce..9f0d28bd 100644 --- a/crates/anstream/src/strip.rs +++ b/crates/anstream/src/strip.rs @@ -37,6 +37,7 @@ where S: std::io::Write, S: IsTerminal, { + /// Returns `true` if the descriptor/handle refers to a terminal/tty. #[inline] pub fn is_terminal(&self) -> bool { self.raw.is_terminal() diff --git a/crates/anstyle-ansi-term/CHANGELOG.md b/crates/anstyle-ansi-term/CHANGELOG.md index c1fe371e..42152209 100644 --- a/crates/anstyle-ansi-term/CHANGELOG.md +++ b/crates/anstyle-ansi-term/CHANGELOG.md @@ -7,9 +7,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] - ReleaseDate -### Compatibility +## [1.0.1] - 2024-05-02 -- Update MSRV to 1.70.0 +### Fixes + +- Drop MSRV to 1.65 ## [1.0.0] - 2023-04-13 @@ -28,7 +30,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [0.1.1] - 2022-08-17 -[Unreleased]: https://github.com/rust-cli/anstyle/compare/anstyle-ansi-term-v1.0.0...HEAD +[Unreleased]: https://github.com/rust-cli/anstyle/compare/anstyle-ansi-term-v1.0.1...HEAD +[1.0.1]: https://github.com/rust-cli/anstyle/compare/anstyle-ansi-term-v1.0.0...anstyle-ansi-term-v1.0.1 [1.0.0]: https://github.com/rust-cli/anstyle/compare/anstyle-ansi-term-v0.2.0...anstyle-ansi-term-v1.0.0 [0.2.0]: https://github.com/rust-cli/anstyle/compare/anstyle-ansi-term-v0.1.2...anstyle-ansi-term-v0.2.0 [0.1.2]: https://github.com/rust-cli/anstyle/compare/anstyle-ansi-term-v0.1.1...anstyle-ansi-term-v0.1.2 diff --git a/crates/anstyle-ansi-term/Cargo.toml b/crates/anstyle-ansi-term/Cargo.toml index 365ca478..fcbcd19d 100644 --- a/crates/anstyle-ansi-term/Cargo.toml +++ b/crates/anstyle-ansi-term/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "anstyle-ansi-term" -version = "1.0.0" +version = "1.0.1" description = "Adapt between ansi_term and anstyle" repository = "https://github.com/rust-cli/anstyle.git" homepage = "https://github.com/rust-cli/anstyle" @@ -11,6 +11,10 @@ edition.workspace = true rust-version.workspace = true include.workspace = true +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] + [package.metadata.release] pre-release-replacements = [ {file="CHANGELOG.md", search="Unreleased", replace="{{version}}", min=1}, @@ -20,7 +24,9 @@ pre-release-replacements = [ {file="CHANGELOG.md", search="", replace="\n[Unreleased]: https://github.com/rust-cli/anstyle/compare/{{tag_name}}...HEAD", exactly=1}, ] - [dependencies] anstyle = { version = "1.0.0", path = "../anstyle" } ansi_term = "0.12.1" + +[lints] +workspace = true diff --git a/crates/anstyle-ansi-term/README.md b/crates/anstyle-ansi-term/README.md index 44fdffa6..c5a37118 100644 --- a/crates/anstyle-ansi-term/README.md +++ b/crates/anstyle-ansi-term/README.md @@ -1,6 +1,6 @@ # anstyle-ansi-term -> Convert from color styling types to [`ansi_term`](https://lib.rs/ansi_term) color types +> Convert between [`ansi_term`](https://lib.rs/ansi_term) and generic styling types [![Documentation](https://img.shields.io/badge/docs-master-blue.svg)][Documentation] ![License](https://img.shields.io/crates/l/anstyle-ansi-term.svg) diff --git a/crates/anstyle-ansi-term/src/lib.rs b/crates/anstyle-ansi-term/src/lib.rs index 10ed7e80..f3d0bbab 100644 --- a/crates/anstyle-ansi-term/src/lib.rs +++ b/crates/anstyle-ansi-term/src/lib.rs @@ -1,19 +1,11 @@ -mod sealed { - pub(crate) trait Sealed {} -} - -trait Ext: sealed::Sealed { - fn to_ansi_term(self) -> ansi_term::Style; -} +//! Convert between [`ansi_term`](https://lib.rs/ansi_term) and generic styling types -impl sealed::Sealed for anstyle::Style {} - -impl Ext for anstyle::Style { - fn to_ansi_term(self) -> ansi_term::Style { - to_ansi_term(self) - } -} +#![cfg_attr(docsrs, feature(doc_auto_cfg))] +#![warn(missing_docs)] +#![warn(clippy::print_stderr)] +#![warn(clippy::print_stdout)] +/// Adapt generic styling to [`ansi_term`] pub fn to_ansi_term(astyle: anstyle::Style) -> ansi_term::Style { let mut style = ansi_term::Style::new(); diff --git a/crates/anstyle-crossterm/CHANGELOG.md b/crates/anstyle-crossterm/CHANGELOG.md index de9366fb..8252e603 100644 --- a/crates/anstyle-crossterm/CHANGELOG.md +++ b/crates/anstyle-crossterm/CHANGELOG.md @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] - ReleaseDate +## [2.0.1] - 2024-05-02 + +### Fixes + +- Drop MSRV to 1.65 + ## [2.0.0] - 2023-09-28 ### Breaking Change @@ -32,7 +38,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [0.1.1] - 2022-10-07 -[Unreleased]: https://github.com/rust-cli/anstyle/compare/anstyle-crossterm-v2.0.0...HEAD +[Unreleased]: https://github.com/rust-cli/anstyle/compare/anstyle-crossterm-v2.0.1...HEAD +[2.0.1]: https://github.com/rust-cli/anstyle/compare/anstyle-crossterm-v2.0.0...anstyle-crossterm-v2.0.1 [2.0.0]: https://github.com/rust-cli/anstyle/compare/anstyle-crossterm-v1.0.0...anstyle-crossterm-v2.0.0 [1.0.0]: https://github.com/rust-cli/anstyle/compare/anstyle-crossterm-v0.2.0...anstyle-crossterm-v1.0.0 [0.2.0]: https://github.com/rust-cli/anstyle/compare/anstyle-crossterm-v0.1.1...anstyle-crossterm-v0.2.0 diff --git a/crates/anstyle-crossterm/Cargo.toml b/crates/anstyle-crossterm/Cargo.toml index d7443b8b..26a196b0 100644 --- a/crates/anstyle-crossterm/Cargo.toml +++ b/crates/anstyle-crossterm/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "anstyle-crossterm" -version = "2.0.0" +version = "2.0.1" description = "Adapt between crossterm and anstyle" repository = "https://github.com/rust-cli/anstyle.git" homepage = "https://github.com/rust-cli/anstyle" @@ -11,6 +11,10 @@ edition.workspace = true rust-version.workspace = true include.workspace = true +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] + [package.metadata.release] pre-release-replacements = [ {file="CHANGELOG.md", search="Unreleased", replace="{{version}}", min=1}, @@ -23,3 +27,6 @@ pre-release-replacements = [ [dependencies] anstyle = { version = "1.0.0", path = "../anstyle" } crossterm = { version = "0.27.0", default-features = false, features = ["windows"] } + +[lints] +workspace = true diff --git a/crates/anstyle-crossterm/README.md b/crates/anstyle-crossterm/README.md index 7a2a1341..dd03ddd2 100644 --- a/crates/anstyle-crossterm/README.md +++ b/crates/anstyle-crossterm/README.md @@ -1,6 +1,6 @@ # anstyle-crossterm -> Convert from color styling types to [`crossterm`](https://lib.rs/crossterm) color types +> Convert between [`crossterm`](https://lib.rs/crossterm) and generic styling types [![Documentation](https://img.shields.io/badge/docs-master-blue.svg)][Documentation] ![License](https://img.shields.io/crates/l/anstyle-crossterm.svg) diff --git a/crates/anstyle-crossterm/src/lib.rs b/crates/anstyle-crossterm/src/lib.rs index 7793caa5..ba844447 100644 --- a/crates/anstyle-crossterm/src/lib.rs +++ b/crates/anstyle-crossterm/src/lib.rs @@ -1,19 +1,11 @@ -mod sealed { - pub(crate) trait Sealed {} -} - -trait Ext: sealed::Sealed { - fn to_crossterm(self) -> crossterm::style::ContentStyle; -} +//! Convert between [`crossterm`](https://lib.rs/crossterm) and [generic styling types][anstyle] -impl sealed::Sealed for anstyle::Style {} - -impl Ext for anstyle::Style { - fn to_crossterm(self) -> crossterm::style::ContentStyle { - to_crossterm(self) - } -} +#![cfg_attr(docsrs, feature(doc_auto_cfg))] +#![warn(missing_docs)] +#![warn(clippy::print_stderr)] +#![warn(clippy::print_stdout)] +/// Adapt generic styling to [`crossterm`] pub fn to_crossterm(astyle: anstyle::Style) -> crossterm::style::ContentStyle { let foreground_color = astyle.get_fg_color().map(to_ansi_color); let background_color = astyle.get_bg_color().map(to_ansi_color); diff --git a/crates/anstyle-git/CHANGELOG.md b/crates/anstyle-git/CHANGELOG.md index 1592d814..a9040046 100644 --- a/crates/anstyle-git/CHANGELOG.md +++ b/crates/anstyle-git/CHANGELOG.md @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] - ReleaseDate +## [1.0.1] - 2024-05-02 + +### Fixes + +- Drop MSRV to 1.65 + ### Compatibility - Update MSRV to 1.70.0 @@ -30,7 +36,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [0.2.1] - 2022-05-19 -[Unreleased]: https://github.com/rust-cli/anstyle/compare/anstyle-git-v1.0.0...HEAD +[Unreleased]: https://github.com/rust-cli/anstyle/compare/anstyle-git-v1.0.1...HEAD +[1.0.1]: https://github.com/rust-cli/anstyle/compare/anstyle-git-v1.0.0...anstyle-git-v1.0.1 [1.0.0]: https://github.com/rust-cli/anstyle/compare/anstyle-git-v0.3.0...anstyle-git-v1.0.0 [0.3.0]: https://github.com/rust-cli/anstyle/compare/anstyle-git-v0.2.3...anstyle-git-v0.3.0 [0.2.3]: https://github.com/rust-cli/anstyle/compare/anstyle-git-v0.2.2...anstyle-git-v0.2.3 diff --git a/crates/anstyle-git/Cargo.toml b/crates/anstyle-git/Cargo.toml index a47f48bc..98522537 100644 --- a/crates/anstyle-git/Cargo.toml +++ b/crates/anstyle-git/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "anstyle-git" -version = "1.0.0" +version = "1.0.1" description = "Parse Git Style Descriptions" repository = "https://github.com/rust-cli/anstyle.git" homepage = "https://github.com/rust-cli/anstyle" @@ -11,6 +11,10 @@ edition.workspace = true rust-version.workspace = true include.workspace = true +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] + [package.metadata.release] pre-release-replacements = [ {file="CHANGELOG.md", search="Unreleased", replace="{{version}}", min=1}, @@ -20,6 +24,8 @@ pre-release-replacements = [ {file="CHANGELOG.md", search="", replace="\n[Unreleased]: https://github.com/rust-cli/anstyle/compare/{{tag_name}}...HEAD", exactly=1}, ] - [dependencies] anstyle = { version = "1.0.0", path = "../anstyle" } + +[lints] +workspace = true diff --git a/crates/anstyle-git/src/lib.rs b/crates/anstyle-git/src/lib.rs index b0eb2696..fb602557 100644 --- a/crates/anstyle-git/src/lib.rs +++ b/crates/anstyle-git/src/lib.rs @@ -11,24 +11,13 @@ //! assert_eq!(hyperlink_style, anstyle::RgbColor(0x00, 0x00, 0xee).on_default() | anstyle::Effects::UNDERLINE); //! ``` -mod sealed { - pub(crate) trait Sealed {} -} - -trait Ext: sealed::Sealed + Sized { - fn parse_git(s: &str) -> Result; -} - -impl sealed::Sealed for anstyle::Style {} - -impl Ext for anstyle::Style { - fn parse_git(s: &str) -> Result { - parse(s) - } -} +#![cfg_attr(docsrs, feature(doc_auto_cfg))] +#![warn(missing_docs)] +#![warn(clippy::print_stderr)] +#![warn(clippy::print_stdout)] /// Parse a string in Git's color configuration syntax into an -/// `anstyle::Style`. +/// [`anstyle::Style`]. pub fn parse(s: &str) -> Result { let mut style = anstyle::Style::new(); let mut num_colors = 0; @@ -90,15 +79,15 @@ pub fn parse(s: &str) -> Result { } _ => { return Err(Error::ExtraColor { - style: s.to_string(), - word: word.to_string(), + style: s.to_owned(), + word: word.to_owned(), }); } } } else { return Err(Error::UnknownWord { - style: s.to_string(), - word: word.to_string(), + style: s.to_owned(), + word: word.to_owned(), }); } } @@ -146,13 +135,23 @@ fn parse_color(word: &str) -> Result, ()> { #[non_exhaustive] pub enum Error { /// An extra color appeared after the foreground and background colors. - ExtraColor { style: String, word: String }, + ExtraColor { + /// Original style + style: String, + /// Extra color + word: String, + }, /// An unknown word appeared. - UnknownWord { style: String, word: String }, + UnknownWord { + /// Original style + style: String, + /// Unknown word + word: String, + }, } impl std::fmt::Display for Error { - fn fmt(&self, fmt: &mut std::fmt::Formatter) -> std::fmt::Result { + fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { Self::ExtraColor { style, word } => { write!( @@ -231,8 +230,8 @@ mod tests { assert_eq!( parse($s), Err($err { - style: $s.to_string(), - word: $word.to_string() + style: $s.to_owned(), + word: $word.to_owned() }) ); }; @@ -272,10 +271,4 @@ mod tests { test!("#blue" => UnknownWord "#blue"); test!("blue#123456" => UnknownWord "blue#123456"); } - - #[test] - fn test_extension_trait() { - let style = anstyle::Style::parse_git("red blue"); - assert_eq!(style.unwrap(), Red.on(Blue)); - } } diff --git a/crates/anstyle-lossy/CHANGELOG.md b/crates/anstyle-lossy/CHANGELOG.md index 0bef95cf..82fb5880 100644 --- a/crates/anstyle-lossy/CHANGELOG.md +++ b/crates/anstyle-lossy/CHANGELOG.md @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] - ReleaseDate +## [1.1.1] - 2024-05-02 + +### Fixes + +- Drop MSRV to 1.65 + ## [1.1.0] - 2024-02-18 ### Compatibility @@ -36,7 +42,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [0.1.1] - 2022-10-07 -[Unreleased]: https://github.com/rust-cli/anstyle/compare/anstyle-lossy-v1.1.0...HEAD +[Unreleased]: https://github.com/rust-cli/anstyle/compare/anstyle-lossy-v1.1.1...HEAD +[1.1.1]: https://github.com/rust-cli/anstyle/compare/anstyle-lossy-v1.1.0...anstyle-lossy-v1.1.1 [1.1.0]: https://github.com/rust-cli/anstyle/compare/anstyle-lossy-v1.0.0...anstyle-lossy-v1.1.0 [1.0.0]: https://github.com/rust-cli/anstyle/compare/anstyle-lossy-v0.2.0...anstyle-lossy-v1.0.0 [0.2.0]: https://github.com/rust-cli/anstyle/compare/anstyle-lossy-v0.1.1...anstyle-lossy-v0.2.0 diff --git a/crates/anstyle-lossy/Cargo.toml b/crates/anstyle-lossy/Cargo.toml index d8ab46fc..d0d7e689 100644 --- a/crates/anstyle-lossy/Cargo.toml +++ b/crates/anstyle-lossy/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "anstyle-lossy" -version = "1.1.0" +version = "1.1.1" description = "Lossy conversion between ANSI Color Codes" repository = "https://github.com/rust-cli/anstyle.git" homepage = "https://github.com/rust-cli/anstyle" @@ -11,6 +11,10 @@ edition.workspace = true rust-version.workspace = true include.workspace = true +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] + [package.metadata.release] pre-release-replacements = [ {file="CHANGELOG.md", search="Unreleased", replace="{{version}}", min=1}, @@ -20,6 +24,8 @@ pre-release-replacements = [ {file="CHANGELOG.md", search="", replace="\n[Unreleased]: https://github.com/rust-cli/anstyle/compare/{{tag_name}}...HEAD", exactly=1}, ] - [dependencies] anstyle = { version = "1.0.0", path = "../anstyle" } + +[lints] +workspace = true diff --git a/crates/anstyle-lossy/src/lib.rs b/crates/anstyle-lossy/src/lib.rs index e2916fa8..e0e868e1 100644 --- a/crates/anstyle-lossy/src/lib.rs +++ b/crates/anstyle-lossy/src/lib.rs @@ -1,7 +1,18 @@ +//! Lossy conversion between ANSI Color Codes + +#![cfg_attr(docsrs, feature(doc_auto_cfg))] +#![warn(missing_docs)] +#![warn(clippy::print_stderr)] +#![warn(clippy::print_stdout)] + pub mod palette; use anstyle::RgbColor as Rgb; +/// Lossily convert from any color to RGB +/// +/// As the palette for 4-bit colors is terminal/user defined, a [`palette::Palette`] must be +/// provided to match against. pub const fn color_to_rgb(color: anstyle::Color, palette: palette::Palette) -> anstyle::RgbColor { match color { anstyle::Color::Ansi(color) => ansi_to_rgb(color, palette), @@ -10,6 +21,10 @@ pub const fn color_to_rgb(color: anstyle::Color, palette: palette::Palette) -> a } } +/// Lossily convert from any color to 256-color +/// +/// As the palette for 4-bit colors is terminal/user defined, a [`palette::Palette`] must be +/// provided to match against. pub const fn color_to_xterm(color: anstyle::Color) -> anstyle::Ansi256Color { match color { anstyle::Color::Ansi(color) => anstyle::Ansi256Color::from_ansi(color), @@ -18,6 +33,10 @@ pub const fn color_to_xterm(color: anstyle::Color) -> anstyle::Ansi256Color { } } +/// Lossily convert from any color to 4-bit color +/// +/// As the palette for 4-bit colors is terminal/user defined, a [`palette::Palette`] must be +/// provided to match against. pub const fn color_to_ansi(color: anstyle::Color, palette: palette::Palette) -> anstyle::AnsiColor { match color { anstyle::Color::Ansi(color) => color, @@ -26,6 +45,10 @@ pub const fn color_to_ansi(color: anstyle::Color, palette: palette::Palette) -> } } +/// Lossily convert from 4-bit color to RGB +/// +/// As the palette for 4-bit colors is terminal/user defined, a [`palette::Palette`] must be +/// provided to match against. pub const fn ansi_to_rgb( color: anstyle::AnsiColor, palette: palette::Palette, @@ -33,6 +56,10 @@ pub const fn ansi_to_rgb( palette.rgb_from_ansi(color) } +/// Lossily convert from 256-color to RGB +/// +/// As 256-color palette is a superset of 4-bit colors and since the palette for 4-bit colors is +/// terminal/user defined, a [`palette::Palette`] must be provided to match against. pub const fn xterm_to_rgb( color: anstyle::Ansi256Color, palette: palette::Palette, @@ -43,6 +70,10 @@ pub const fn xterm_to_rgb( } } +/// Lossily convert from the 256-color palette to 4-bit color +/// +/// As the palette for 4-bit colors is terminal/user defined, a [`palette::Palette`] must be +/// provided to match against. pub const fn xterm_to_ansi( color: anstyle::Ansi256Color, palette: palette::Palette, @@ -71,6 +102,10 @@ pub const fn xterm_to_ansi( } } +/// Lossily convert an RGB value to a 4-bit color +/// +/// As the palette for 4-bit colors is terminal/user defined, a [`palette::Palette`] must be +/// provided to match against. pub const fn rgb_to_ansi( color: anstyle::RgbColor, palette: palette::Palette, @@ -78,6 +113,7 @@ pub const fn rgb_to_ansi( palette.find_match(color) } +/// Lossily convert an RGB value to the 256-color palette pub const fn rgb_to_xterm(color: anstyle::RgbColor) -> anstyle::Ansi256Color { // Skip placeholders let index = find_xterm_match(color); diff --git a/crates/anstyle-lossy/src/palette.rs b/crates/anstyle-lossy/src/palette.rs index 1a06bbc2..17922f7b 100644 --- a/crates/anstyle-lossy/src/palette.rs +++ b/crates/anstyle-lossy/src/palette.rs @@ -3,11 +3,14 @@ //! Based on [wikipedia](https://en.wikipedia.org/wiki/ANSI_escape_code#3-bit_and_4-bit) use anstyle::RgbColor as Rgb; +/// A color palette for rendering 4-bit [`anstyle::AnsiColor`] +#[allow(clippy::exhaustive_structs)] #[derive(Copy, Clone, PartialEq, Eq, Debug)] pub struct Palette(pub RawPalette); type RawPalette = [Rgb; 16]; impl Palette { + /// Look up the [`anstyle::RgbColor`] in the palette pub const fn get(&self, color: anstyle::AnsiColor) -> Rgb { let color = anstyle::Ansi256Color::from_ansi(color); *self.get_ansi256_ref(color) @@ -45,15 +48,14 @@ impl Palette { index += 1; } - match anstyle::Ansi256Color(best_index as u8).into_ansi() { - Some(color) => color, - None => { - // Panic - #[allow(clippy::no_effect)] - ["best_index is out of bounds"][best_index]; - // Make compiler happy - anstyle::AnsiColor::Black - } + if let Some(color) = anstyle::Ansi256Color(best_index as u8).into_ansi() { + color + } else { + // Panic + #[allow(clippy::no_effect)] + ["best_index is out of bounds"][best_index]; + // Make compiler happy + anstyle::AnsiColor::Black } } } @@ -80,12 +82,15 @@ impl From for Palette { } } +/// Platform-specific default #[cfg(not(windows))] pub use VGA as DEFAULT; +/// Platform-specific default #[cfg(windows)] pub use WIN10_CONSOLE as DEFAULT; +/// Typical colors that are used when booting PCs and leaving them in text mode pub const VGA: Palette = Palette([ Rgb(0, 0, 0), Rgb(170, 0, 0), @@ -105,6 +110,7 @@ pub const VGA: Palette = Palette([ Rgb(255, 255, 255), ]); +/// Campbell theme, used as of Windows 10 version 1709. pub const WIN10_CONSOLE: Palette = Palette([ Rgb(12, 12, 12), Rgb(197, 15, 31), diff --git a/crates/anstyle-ls/CHANGELOG.md b/crates/anstyle-ls/CHANGELOG.md index 0449a1b1..d5f6f376 100644 --- a/crates/anstyle-ls/CHANGELOG.md +++ b/crates/anstyle-ls/CHANGELOG.md @@ -7,9 +7,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] - ReleaseDate -### Compatibility +## [1.0.2] - 2024-05-02 -- Update MSRV to 1.70.0 +### Fixes + +- Drop MSRV to 1.65 ## [1.0.1] - 2023-06-20 @@ -28,7 +30,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [0.1.1] - 2022-10-07 -[Unreleased]: https://github.com/rust-cli/anstyle/compare/anstyle-ls-v1.0.1...HEAD +[Unreleased]: https://github.com/rust-cli/anstyle/compare/anstyle-ls-v1.0.2...HEAD +[1.0.2]: https://github.com/rust-cli/anstyle/compare/anstyle-ls-v1.0.1...anstyle-ls-v1.0.2 [1.0.1]: https://github.com/rust-cli/anstyle/compare/anstyle-ls-v1.0.0...anstyle-ls-v1.0.1 [1.0.0]: https://github.com/rust-cli/anstyle/compare/anstyle-ls-v0.2.0...anstyle-ls-v1.0.0 [0.2.0]: https://github.com/rust-cli/anstyle/compare/anstyle-ls-v0.1.1...anstyle-ls-v0.2.0 diff --git a/crates/anstyle-ls/Cargo.toml b/crates/anstyle-ls/Cargo.toml index 22502d9e..e18f0a31 100644 --- a/crates/anstyle-ls/Cargo.toml +++ b/crates/anstyle-ls/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "anstyle-ls" -version = "1.0.1" +version = "1.0.2" description = "Parse LS_COLORS Style Descriptions" repository = "https://github.com/rust-cli/anstyle.git" homepage = "https://github.com/rust-cli/anstyle" @@ -11,6 +11,10 @@ edition.workspace = true rust-version.workspace = true include.workspace = true +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] + [package.metadata.release] pre-release-replacements = [ {file="CHANGELOG.md", search="Unreleased", replace="{{version}}", min=1}, @@ -20,6 +24,8 @@ pre-release-replacements = [ {file="CHANGELOG.md", search="", replace="\n[Unreleased]: https://github.com/rust-cli/anstyle/compare/{{tag_name}}...HEAD", exactly=1}, ] - [dependencies] anstyle = { version = "1.0.0", path = "../anstyle" } + +[lints] +workspace = true diff --git a/crates/anstyle-ls/src/lib.rs b/crates/anstyle-ls/src/lib.rs index 3a7e6457..d185368f 100644 --- a/crates/anstyle-ls/src/lib.rs +++ b/crates/anstyle-ls/src/lib.rs @@ -8,21 +8,10 @@ //! assert_eq!(style, anstyle::AnsiColor::Blue.on_default() | anstyle::Effects::ITALIC); //! ``` -mod sealed { - pub(crate) trait Sealed {} -} - -trait Ext: sealed::Sealed + Sized { - fn parse_ls(code: &str) -> Option; -} - -impl sealed::Sealed for anstyle::Style {} - -impl Ext for anstyle::Style { - fn parse_ls(code: &str) -> Option { - parse(code) - } -} +#![cfg_attr(docsrs, feature(doc_auto_cfg))] +#![warn(missing_docs)] +#![warn(clippy::print_stderr)] +#![warn(clippy::print_stdout)] /// Parse a string in `LS_COLORS`'s color configuration syntax into an /// `ansi_term::Style`. @@ -93,7 +82,7 @@ pub fn parse(code: &str) -> Option { (Some(5), Some(color)) => fg_color = Some(anstyle::Ansi256Color(color).into()), (Some(2), Some(red)) => match (parts.pop_front(), parts.pop_front()) { (Some(green), Some(blue)) => { - fg_color = Some(anstyle::RgbColor(red, green, blue).into()) + fg_color = Some(anstyle::RgbColor(red, green, blue).into()); } _ => { break; @@ -116,7 +105,7 @@ pub fn parse(code: &str) -> Option { (Some(5), Some(color)) => bg_color = Some(anstyle::Ansi256Color(color).into()), (Some(2), Some(red)) => match (parts.pop_front(), parts.pop_front()) { (Some(green), Some(blue)) => { - bg_color = Some(anstyle::RgbColor(red, green, blue).into()) + bg_color = Some(anstyle::RgbColor(red, green, blue).into()); } _ => { break; @@ -129,11 +118,11 @@ pub fn parse(code: &str) -> Option { 49 => bg_color = None, 58 => match (parts.pop_front(), parts.pop_front()) { (Some(5), Some(color)) => { - underline_color = Some(anstyle::Ansi256Color(color).into()) + underline_color = Some(anstyle::Ansi256Color(color).into()); } (Some(2), Some(red)) => match (parts.pop_front(), parts.pop_front()) { (Some(green), Some(blue)) => { - underline_color = Some(anstyle::RgbColor(red, green, blue).into()) + underline_color = Some(anstyle::RgbColor(red, green, blue).into()); } _ => { break; @@ -181,7 +170,7 @@ mod tests { #[track_caller] fn assert_style(code: &str, expected: impl Into) { - let actual = anstyle::Style::parse_ls(code).unwrap(); + let actual = parse(code).unwrap(); let expected = expected.into(); assert_eq!(actual, expected); } @@ -206,9 +195,9 @@ mod tests { #[test] fn parse_reject() { - assert_eq!(None, anstyle::Style::parse_ls("a")); - assert_eq!(None, anstyle::Style::parse_ls("1;")); - assert_eq!(None, anstyle::Style::parse_ls("33; 42")); + assert_eq!(None, parse("a")); + assert_eq!(None, parse("1;")); + assert_eq!(None, parse("33; 42")); } #[test] diff --git a/crates/anstyle-owo-colors/CHANGELOG.md b/crates/anstyle-owo-colors/CHANGELOG.md index e5407ea6..c2a900c7 100644 --- a/crates/anstyle-owo-colors/CHANGELOG.md +++ b/crates/anstyle-owo-colors/CHANGELOG.md @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] - ReleaseDate +## [2.0.1] - 2024-05-02 + +### Fixes + +- Drop MSRV to 1.65 + ## [2.0.0] - 2024-02-18 ### Compatibility @@ -41,7 +47,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [0.1.1] - 2022-05-18 -[Unreleased]: https://github.com/rust-cli/anstyle/compare/anstyle-owo-colors-v2.0.0...HEAD +[Unreleased]: https://github.com/rust-cli/anstyle/compare/anstyle-owo-colors-v2.0.1...HEAD +[2.0.1]: https://github.com/rust-cli/anstyle/compare/anstyle-owo-colors-v2.0.0...anstyle-owo-colors-v2.0.1 [2.0.0]: https://github.com/rust-cli/anstyle/compare/anstyle-owo-colors-v1.0.1...anstyle-owo-colors-v2.0.0 [1.0.1]: https://github.com/rust-cli/anstyle/compare/anstyle-owo-colors-v1.0.0...anstyle-owo-colors-v1.0.1 [1.0.0]: https://github.com/rust-cli/anstyle/compare/anstyle-owo-colors-v0.3.0...anstyle-owo-colors-v1.0.0 diff --git a/crates/anstyle-owo-colors/Cargo.toml b/crates/anstyle-owo-colors/Cargo.toml index c00ee710..1920b85b 100644 --- a/crates/anstyle-owo-colors/Cargo.toml +++ b/crates/anstyle-owo-colors/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "anstyle-owo-colors" -version = "2.0.0" +version = "2.0.1" description = "Adapt between owo-colors and anstyle" repository = "https://github.com/rust-cli/anstyle.git" homepage = "https://github.com/rust-cli/anstyle" @@ -11,6 +11,10 @@ edition.workspace = true rust-version.workspace = true include.workspace = true +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] + [package.metadata.release] pre-release-replacements = [ {file="CHANGELOG.md", search="Unreleased", replace="{{version}}", min=1}, @@ -20,7 +24,9 @@ pre-release-replacements = [ {file="CHANGELOG.md", search="", replace="\n[Unreleased]: https://github.com/rust-cli/anstyle/compare/{{tag_name}}...HEAD", exactly=1}, ] - [dependencies] anstyle = { version = "1.0.0", path = "../anstyle" } owo-colors = "4.0.0" + +[lints] +workspace = true diff --git a/crates/anstyle-owo-colors/README.md b/crates/anstyle-owo-colors/README.md index 2c71fbe2..e59e6ae5 100644 --- a/crates/anstyle-owo-colors/README.md +++ b/crates/anstyle-owo-colors/README.md @@ -1,6 +1,6 @@ # anstyle-owo-colors -> Convert from color styling types to [owo-colors](https://lib.rs/owo-colors) color types +> Convert between [owo-colors](https://lib.rs/owo-colors) and generic styling types [![Documentation](https://img.shields.io/badge/docs-master-blue.svg)][Documentation] ![License](https://img.shields.io/crates/l/anstyle-owo-colors.svg) diff --git a/crates/anstyle-owo-colors/src/lib.rs b/crates/anstyle-owo-colors/src/lib.rs index 6c45cefa..4e9625f1 100644 --- a/crates/anstyle-owo-colors/src/lib.rs +++ b/crates/anstyle-owo-colors/src/lib.rs @@ -1,19 +1,11 @@ -mod sealed { - pub(crate) trait Sealed {} -} - -trait Ext: sealed::Sealed { - fn to_owo(self) -> owo_colors::Style; -} +//! Convert between [owo-colors](https://lib.rs/owo-colors) and generic styling types -impl sealed::Sealed for anstyle::Style {} - -impl Ext for anstyle::Style { - fn to_owo(self) -> owo_colors::Style { - to_owo_style(self) - } -} +#![cfg_attr(docsrs, feature(doc_auto_cfg))] +#![warn(missing_docs)] +#![warn(clippy::print_stderr)] +#![warn(clippy::print_stdout)] +/// Adapt generic styling to [`owo_colors`] pub fn to_owo_style(style: anstyle::Style) -> owo_colors::Style { let fg = style.get_fg_color().map(to_owo_colors); let bg = style.get_bg_color().map(to_owo_colors); @@ -53,6 +45,7 @@ pub fn to_owo_style(style: anstyle::Style) -> owo_colors::Style { style } +/// Adapt generic colors to [`owo_colors`] pub fn to_owo_colors(color: anstyle::Color) -> owo_colors::DynColors { match color { anstyle::Color::Ansi(ansi) => owo_colors::DynColors::Ansi(ansi_to_owo_colors_color(ansi)), diff --git a/crates/anstyle-parse/CHANGELOG.md b/crates/anstyle-parse/CHANGELOG.md index 4451f4ec..4eca338c 100644 --- a/crates/anstyle-parse/CHANGELOG.md +++ b/crates/anstyle-parse/CHANGELOG.md @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] - ReleaseDate +## [0.2.4] - 2024-05-02 + +### Fixes + +- Drop MSRV to 1.65 + ## [0.2.3] - 2023-12-04 ## [0.2.2] - 2023-09-28 @@ -30,7 +36,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [0.0.1] - 2023-03-07 -[Unreleased]: https://github.com/rust-cli/anstyle/compare/anstyle-parse-v0.2.3...HEAD +[Unreleased]: https://github.com/rust-cli/anstyle/compare/anstyle-parse-v0.2.4...HEAD +[0.2.4]: https://github.com/rust-cli/anstyle/compare/anstyle-parse-v0.2.3...anstyle-parse-v0.2.4 [0.2.3]: https://github.com/rust-cli/anstyle/compare/anstyle-parse-v0.2.2...anstyle-parse-v0.2.3 [0.2.2]: https://github.com/rust-cli/anstyle/compare/anstyle-parse-v0.2.1...anstyle-parse-v0.2.2 [0.2.1]: https://github.com/rust-cli/anstyle/compare/anstyle-parse-v0.2.0...anstyle-parse-v0.2.1 diff --git a/crates/anstyle-parse/Cargo.toml b/crates/anstyle-parse/Cargo.toml index eef1df3d..d7de2a91 100644 --- a/crates/anstyle-parse/Cargo.toml +++ b/crates/anstyle-parse/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "anstyle-parse" -version = "0.2.3" +version = "0.2.4" description = "Parse ANSI Style Escapes" repository = "https://github.com/rust-cli/anstyle.git" homepage = "https://github.com/rust-cli/anstyle" @@ -11,6 +11,10 @@ edition.workspace = true rust-version.workspace = true include.workspace = true +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] + [package.metadata.release] pre-release-replacements = [ {file="CHANGELOG.md", search="Unreleased", replace="{{version}}", min=1}, @@ -39,4 +43,7 @@ vte_generate_state_changes = { version = "0.1.1" } [[bench]] name = "parse" harness = false -test = true +required-features = ["utf8"] + +[lints] +workspace = true diff --git a/crates/anstyle-parse/benches/parse.rs b/crates/anstyle-parse/benches/parse.rs index 38469671..92d7f668 100644 --- a/crates/anstyle-parse/benches/parse.rs +++ b/crates/anstyle-parse/benches/parse.rs @@ -1,6 +1,9 @@ use std::hint::black_box; -use anstyle_parse::*; +use anstyle_parse::DefaultCharAccumulator; +use anstyle_parse::Params; +use anstyle_parse::Parser; +use anstyle_parse::Perform; #[divan::bench(args = DATA)] fn advance(data: &Data) { @@ -35,7 +38,7 @@ fn state_change(data: &Data) { } #[divan::bench(args = DATA)] -fn state_change_strip_str(bencher: divan::Bencher, data: &Data) { +fn state_change_strip_str(bencher: divan::Bencher<'_, '_>, data: &Data) { if let Ok(content) = std::str::from_utf8(data.content()) { bencher .with_inputs(|| content) @@ -43,7 +46,7 @@ fn state_change_strip_str(bencher: divan::Bencher, data: &Data) { let stripped = strip_str(content); black_box(stripped) - }) + }); } } @@ -141,6 +144,7 @@ fn strip_str(content: &str) -> String { bytes = next; } + #[allow(clippy::unwrap_used)] String::from_utf8(stripped).unwrap() } @@ -162,14 +166,14 @@ const DATA: &[Data] = &[ ]; #[derive(Debug)] -pub struct Data(&'static str, &'static [u8]); +struct Data(&'static str, &'static [u8]); impl Data { - pub const fn name(&self) -> &'static str { + const fn name(&self) -> &'static str { self.0 } - pub const fn content(&self) -> &'static [u8] { + const fn content(&self) -> &'static [u8] { self.1 } } diff --git a/crates/anstyle-parse/src/lib.rs b/crates/anstyle-parse/src/lib.rs index e3d04c9a..117a1842 100644 --- a/crates/anstyle-parse/src/lib.rs +++ b/crates/anstyle-parse/src/lib.rs @@ -29,6 +29,10 @@ //! //! [Paul Williams' ANSI parser state machine]: https://vt100.net/emu/dec_ansi_parser #![cfg_attr(not(test), no_std)] +#![cfg_attr(docsrs, feature(doc_auto_cfg))] +#![allow(missing_docs)] +#![warn(clippy::print_stderr)] +#![warn(clippy::print_stdout)] #[cfg(not(feature = "core"))] extern crate alloc; @@ -53,6 +57,7 @@ const MAX_OSC_PARAMS: usize = 16; const MAX_OSC_RAW: usize = 1024; /// Parser for raw _VTE_ protocol which delegates actions to a [`Perform`] +#[allow(unused_qualifications)] #[derive(Default, Clone, Debug, PartialEq, Eq)] pub struct Parser { state: State, @@ -162,9 +167,9 @@ where } } - /// Separate method for osc_dispatch that borrows self as read-only + /// Separate method for `osc_dispatch` that borrows self as read-only /// - /// The aliasing is needed here for multiple slices into self.osc_raw + /// The aliasing is needed here for multiple slices into `self.osc_raw` #[inline] fn osc_dispatch(&self, performer: &mut P, byte: u8) { let mut slices: [MaybeUninit<&[u8]>; MAX_OSC_PARAMS] = @@ -322,12 +327,14 @@ pub trait CharAccumulator: Default { fn add(&mut self, byte: u8) -> Option; } +/// Most flexible [`CharAccumulator`] for [`Parser`] based on active features #[cfg(feature = "utf8")] pub type DefaultCharAccumulator = Utf8Parser; #[cfg(not(feature = "utf8"))] pub type DefaultCharAccumulator = AsciiParser; /// Only allow parsing 7-bit ASCII +#[allow(clippy::exhaustive_structs)] #[derive(Default, Clone, Debug, PartialEq, Eq)] pub struct AsciiParser; diff --git a/crates/anstyle-parse/src/state/codegen.rs b/crates/anstyle-parse/src/state/codegen.rs index 8c2bf550..58a2507b 100644 --- a/crates/anstyle-parse/src/state/codegen.rs +++ b/crates/anstyle-parse/src/state/codegen.rs @@ -52,7 +52,7 @@ pub(crate) const STATE_CHANGES: [[u8; 256]; 16] = ["# /// This is the state change table. It's indexed first by current state and then by the next /// character in the pty stream. -pub static STATE_CHANGES: [[u8; 256]; 16] = state_changes(); +pub(crate) static STATE_CHANGES: [[u8; 256]; 16] = state_changes(); generate_state_changes!(state_changes, { Anywhere { 0x18 => (Ground, Execute), diff --git a/crates/anstyle-parse/src/state/definitions.rs b/crates/anstyle-parse/src/state/definitions.rs index c4e76735..4b03a9ad 100644 --- a/crates/anstyle-parse/src/state/definitions.rs +++ b/crates/anstyle-parse/src/state/definitions.rs @@ -1,3 +1,5 @@ +#![allow(clippy::exhaustive_enums)] + use core::mem; #[derive(Debug, Copy, Clone, PartialEq, Eq)] @@ -110,7 +112,7 @@ const ACTIONS: [Action; 16] = [ /// /// Bad things will happen if those invariants are violated. #[inline(always)] -pub const fn unpack(delta: u8) -> (State, Action) { +pub(crate) const fn unpack(delta: u8) -> (State, Action) { unsafe { ( // State is stored in bottom 4 bits @@ -123,7 +125,7 @@ pub const fn unpack(delta: u8) -> (State, Action) { #[inline(always)] #[cfg(test)] -pub const fn pack(state: State, action: Action) -> u8 { +pub(crate) const fn pack(state: State, action: Action) -> u8 { (action as u8) << 4 | state as u8 } diff --git a/crates/anstyle-parse/src/state/mod.rs b/crates/anstyle-parse/src/state/mod.rs index 91942059..a1d86918 100644 --- a/crates/anstyle-parse/src/state/mod.rs +++ b/crates/anstyle-parse/src/state/mod.rs @@ -1,3 +1,5 @@ +//! ANSI escape code parsing state machine + #[cfg(test)] mod codegen; mod definitions; diff --git a/crates/anstyle-query/CHANGELOG.md b/crates/anstyle-query/CHANGELOG.md index 1f3256c2..6317c5c4 100644 --- a/crates/anstyle-query/CHANGELOG.md +++ b/crates/anstyle-query/CHANGELOG.md @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] - ReleaseDate +## [1.0.3] - 2024-05-02 + +### Fixes + +- Drop MSRV to 1.65 + ## [1.0.2] - 2023-12-08 ### Features @@ -22,7 +28,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [1.0.0] - 2023-04-13 -[Unreleased]: https://github.com/rust-cli/anstyle/compare/anstyle-query-v1.0.2...HEAD +[Unreleased]: https://github.com/rust-cli/anstyle/compare/anstyle-query-v1.0.3...HEAD +[1.0.3]: https://github.com/rust-cli/anstyle/compare/anstyle-query-v1.0.2...anstyle-query-v1.0.3 [1.0.2]: https://github.com/rust-cli/anstyle/compare/anstyle-query-v1.0.1...anstyle-query-v1.0.2 [1.0.1]: https://github.com/rust-cli/anstyle/compare/anstyle-query-v1.0.0...anstyle-query-v1.0.1 [1.0.0]: https://github.com/rust-cli/anstyle/compare/c4423c1...anstyle-query-v1.0.0 diff --git a/crates/anstyle-query/Cargo.toml b/crates/anstyle-query/Cargo.toml index d2bcf8cc..69870b89 100644 --- a/crates/anstyle-query/Cargo.toml +++ b/crates/anstyle-query/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "anstyle-query" -version = "1.0.2" +version = "1.0.3" description = "Look up colored console capabilities" repository = "https://github.com/rust-cli/anstyle" categories = ["command-line-interface"] @@ -10,6 +10,10 @@ edition.workspace = true rust-version.workspace = true include.workspace = true +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] + [package.metadata.release] pre-release-replacements = [ {file="CHANGELOG.md", search="Unreleased", replace="{{version}}", min=1}, @@ -21,3 +25,6 @@ pre-release-replacements = [ [target.'cfg(windows)'.dependencies] windows-sys = { version = "0.52.0", features = ["Win32_System_Console", "Win32_Foundation"] } + +[lints] +workspace = true diff --git a/crates/anstyle-query/examples/query.rs b/crates/anstyle-query/examples/query.rs index 2e5f0219..e5d66205 100644 --- a/crates/anstyle-query/examples/query.rs +++ b/crates/anstyle-query/examples/query.rs @@ -1,3 +1,5 @@ +//! Report a terminal's capabilities + fn main() { println!("clicolor: {:?}", anstyle_query::clicolor()); println!("clicolor_force: {}", anstyle_query::clicolor_force()); diff --git a/crates/anstyle-query/src/lib.rs b/crates/anstyle-query/src/lib.rs index 4b3745a5..cee820d5 100644 --- a/crates/anstyle-query/src/lib.rs +++ b/crates/anstyle-query/src/lib.rs @@ -1,3 +1,10 @@ +//! Low level terminal capability lookups + +#![cfg_attr(docsrs, feature(doc_auto_cfg))] +#![warn(missing_docs)] +#![warn(clippy::print_stderr)] +#![warn(clippy::print_stdout)] + pub mod windows; /// Check [CLICOLOR] status diff --git a/crates/anstyle-query/src/windows.rs b/crates/anstyle-query/src/windows.rs index a8ce404a..ba4971aa 100644 --- a/crates/anstyle-query/src/windows.rs +++ b/crates/anstyle-query/src/windows.rs @@ -64,7 +64,7 @@ mod windows_console { } } -/// Enable ANSI escape codes (ENABLE_VIRTUAL_TERMINAL_PROCESSING) +/// Enable ANSI escape codes ([`ENABLE_VIRTUAL_TERMINAL_PROCESSING`](https://learn.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences#output-sequences)) /// /// For non-windows systems, returns `None` pub fn enable_ansi_colors() -> Option { diff --git a/crates/anstyle-roff/CHANGELOG.md b/crates/anstyle-roff/CHANGELOG.md index fae4d931..295048db 100644 --- a/crates/anstyle-roff/CHANGELOG.md +++ b/crates/anstyle-roff/CHANGELOG.md @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] - ReleaseDate +## [0.3.3] - 2024-05-02 + +### Fixes + +- Drop MSRV to 1.65 + ## [0.3.2] - 2023-09-28 ### Compatibility @@ -30,7 +36,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [0.1.0] - 2023-02-10 -[Unreleased]: https://github.com/rust-cli/anstyle/compare/anstyle-roff-v0.3.2...HEAD +[Unreleased]: https://github.com/rust-cli/anstyle/compare/anstyle-roff-v0.3.3...HEAD +[0.3.3]: https://github.com/rust-cli/anstyle/compare/anstyle-roff-v0.3.2...anstyle-roff-v0.3.3 [0.3.2]: https://github.com/rust-cli/anstyle/compare/anstyle-roff-v0.3.1...anstyle-roff-v0.3.2 [0.3.1]: https://github.com/rust-cli/anstyle/compare/anstyle-roff-v0.3.0...anstyle-roff-v0.3.1 [0.3.0]: https://github.com/rust-cli/anstyle/compare/anstyle-roff-v0.2.0...anstyle-roff-v0.3.0 diff --git a/crates/anstyle-roff/Cargo.toml b/crates/anstyle-roff/Cargo.toml index ce15f223..4c5eb9b5 100644 --- a/crates/anstyle-roff/Cargo.toml +++ b/crates/anstyle-roff/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "anstyle-roff" -version = "0.3.2" +version = "0.3.3" description = "Adapt between anstyle and roff" repository = "https://github.com/rust-cli/anstyle.git" homepage = "https://github.com/rust-cli/anstyle" @@ -11,6 +11,10 @@ edition.workspace = true rust-version.workspace = true include.workspace = true +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] + [package.metadata.release] pre-release-replacements = [ {file="CHANGELOG.md", search="Unreleased", replace="{{version}}", min=1}, @@ -28,3 +32,6 @@ cansi = "2.2.1" [dev-dependencies] snapbox = "0.5.0" + +[lints] +workspace = true diff --git a/crates/anstyle-roff/src/lib.rs b/crates/anstyle-roff/src/lib.rs index 4ca1f049..803b78f8 100644 --- a/crates/anstyle-roff/src/lib.rs +++ b/crates/anstyle-roff/src/lib.rs @@ -2,6 +2,11 @@ //! Currently uses [roff](https://docs.rs/roff/0.2.1/roff/) as the engine for generating //! roff output. +#![cfg_attr(docsrs, feature(doc_auto_cfg))] +#![warn(missing_docs)] +#![warn(clippy::print_stderr)] +#![warn(clippy::print_stdout)] + mod styled_str; use anstyle::{Ansi256Color, AnsiColor, Color, RgbColor, Style}; use anstyle_lossy::palette::Palette; @@ -11,14 +16,14 @@ use styled_str::StyledStr; /// Static Strings defining ROFF Control Requests mod control_requests { /// Control to Create a Color definition - pub const CREATE_COLOR: &str = "defcolor"; + pub(crate) const CREATE_COLOR: &str = "defcolor"; /// Roff control request to set background color (fill color) - pub const BACKGROUND: &str = "fcolor"; + pub(crate) const BACKGROUND: &str = "fcolor"; /// Roff control request to set foreground color (glyph color) - pub const FOREGROUND: &str = "gcolor"; + pub(crate) const FOREGROUND: &str = "gcolor"; } -/// Generate A RoffStyle from Style +/// Generate a [`Roff`] from ANSI escape codes /// /// ```rust /// let text = "\u{1b}[44;31mtest\u{1b}[0m"; @@ -43,7 +48,7 @@ pub fn to_roff(styled_text: &str) -> Roff { doc } -fn set_effects_and_text(styled: &StyledStr, doc: &mut Roff) { +fn set_effects_and_text(styled: &StyledStr<'_>, doc: &mut Roff) { // Roff (the crate) only supports these inline commands // - Bold // - Italic @@ -69,7 +74,7 @@ fn has_bright_fg(style: &Style) -> bool { .unwrap_or(false) } -/// Check if Color is an AnsiColor::Bright* variant +/// Check if [`Color`] is an [`AnsiColor::Bright*`][AnsiColor] variant fn is_bright(fg_color: &Color) -> bool { if let Color::Ansi(color) = fg_color { matches!( @@ -90,7 +95,7 @@ fn is_bright(fg_color: &Color) -> bool { type ColorSet<'a> = (&'a Option, &'a Option); -fn set_color(colors: ColorSet, doc: &mut Roff) { +fn set_color(colors: ColorSet<'_>, doc: &mut Roff) { add_color_to_roff(doc, control_requests::FOREGROUND, colors.0); add_color_to_roff(doc, control_requests::BACKGROUND, colors.1); } @@ -116,7 +121,7 @@ fn add_color_to_roff(doc: &mut Roff, control_request: &str, color: &Option { // TODO: get rid of "default" hardcoded str? @@ -143,7 +148,7 @@ fn to_hex(rgb: &RgbColor) -> String { } /// Map Color and Bright Variants to Roff Color styles -fn ansi_color_to_roff(color: &anstyle::AnsiColor) -> &'static str { +fn ansi_color_to_roff(color: &AnsiColor) -> &'static str { match color { AnsiColor::Black | AnsiColor::BrightBlack => "black", AnsiColor::Red | AnsiColor::BrightRed => "red", diff --git a/crates/anstyle-roff/src/styled_str.rs b/crates/anstyle-roff/src/styled_str.rs index 59ffb67e..cf5030d8 100644 --- a/crates/anstyle-roff/src/styled_str.rs +++ b/crates/anstyle-roff/src/styled_str.rs @@ -3,8 +3,8 @@ use anstyle::{AnsiColor, Color as AColor, Effects, Style}; use cansi::{v3::CategorisedSlice, Color, Intensity}; -/// Produce a stream of StyledStr from text that contains ansi escape sequences -pub(crate) fn styled_stream(text: &str) -> impl Iterator { +/// Produce a stream of [`StyledStr`] from text that contains ansi escape sequences +pub(crate) fn styled_stream(text: &str) -> impl Iterator> { let categorized = cansi::v3::categorise_text(text); categorized.into_iter().map(|x| x.into()) } @@ -12,8 +12,8 @@ pub(crate) fn styled_stream(text: &str) -> impl Iterator { /// Represents a Section of text, along with the desired styling for it #[derive(Debug, Default, Clone, Copy)] pub(crate) struct StyledStr<'text> { - pub text: &'text str, - pub style: Style, + pub(crate) text: &'text str, + pub(crate) style: Style, } impl<'text> From> for StyledStr<'text> { @@ -33,7 +33,7 @@ impl<'text> From> for StyledStr<'text> { } } -fn create_effects(category: &CategorisedSlice) -> Effects { +fn create_effects(category: &CategorisedSlice<'_>) -> Effects { Effects::new() .set(Effects::ITALIC, category.italic.unwrap_or(false)) .set(Effects::BLINK, category.blink.unwrap_or(false)) @@ -83,14 +83,16 @@ mod tests { use super::*; - /// Creates a CategorisedSlice for Testing + /// Creates a [`CategorisedSlice`] for Testing /// - /// styled_str!( Text, [Color:COLOR_SET] [Intensity:INTENSITY_SET] [Effects:EFFECTS_SET]) + /// ```rust + /// styled_str!(Text, [Color:COLOR_SET] [Intensity:INTENSITY_SET] [Effects:EFFECTS_SET]) + /// ``` /// /// Where: - /// COLOR_SET={fg|bg}: - /// INTENSITY_SET= - /// EFFECTS_SET = {"underline"|"italic"|"blink"|"reversed"|"strikethrough"|"hidden"};+ + /// `COLOR_SET={fg|bg}:` + /// `INTENSITY_SET=` + /// `EFFECTS_SET={"underline"|"italic"|"blink"|"reversed"|"strikethrough"|"hidden"};+` macro_rules! styled_str { ($text: literal, $(Color:$color_key:literal:$color_val:expr;)* $(Intensity:$intensity:expr;)? $(Effects:$($key:literal;)+)? ) => { { @@ -137,14 +139,14 @@ mod tests { #[test] fn from_categorized_underlined() { let categorised = styled_str!("Hello", Effects:"underline";); - let styled_str: StyledStr = categorised.into(); + let styled_str: StyledStr<'_> = categorised.into(); assert!(styled_str.style.get_effects().contains(Effects::UNDERLINE)); } #[test] fn from_categorized_underlined_striketrhough() { let categorised = styled_str!("Hello", Effects:"underline";"strikethrough";); - let styled_str: StyledStr = categorised.into(); + let styled_str: StyledStr<'_> = categorised.into(); assert!(styled_str.style.get_effects().contains(Effects::UNDERLINE)); assert!(styled_str .style @@ -155,21 +157,21 @@ mod tests { #[test] fn from_categorized_blink() { let categorised = styled_str!("Hello", Effects:"blink";); - let styled_str: StyledStr = categorised.into(); + let styled_str: StyledStr<'_> = categorised.into(); assert!(styled_str.style.get_effects().contains(Effects::BLINK)); } #[test] fn from_categorized_reversed() { let categorised = styled_str!("Hello", Effects:"reversed";); - let styled_str: StyledStr = categorised.into(); + let styled_str: StyledStr<'_> = categorised.into(); assert!(styled_str.style.get_effects().contains(Effects::INVERT)); } #[test] fn from_categorized_strikthrough() { let categorised = styled_str!("Hello", Effects:"strikethrough";); - let styled_str: StyledStr = categorised.into(); + let styled_str: StyledStr<'_> = categorised.into(); assert!(styled_str .style .get_effects() @@ -179,14 +181,14 @@ mod tests { #[test] fn from_categorized_hidden() { let categorised = styled_str!("Hello", Effects:"hidden";); - let styled_str: StyledStr = categorised.into(); + let styled_str: StyledStr<'_> = categorised.into(); assert!(styled_str.style.get_effects().contains(Effects::HIDDEN)); } #[test] fn from_categorized_bg() { let categorised = styled_str!("Hello", Color:"bg":Color::Blue;); - let styled_str: StyledStr = categorised.into(); + let styled_str: StyledStr<'_> = categorised.into(); assert!(matches!( styled_str.style.get_bg_color(), Some(AColor::Ansi(AnsiColor::Blue)) @@ -196,7 +198,7 @@ mod tests { #[test] fn from_categorized_fg() { let categorised = styled_str!("Hello", Color:"fg":Color::Blue;); - let styled_str: StyledStr = categorised.into(); + let styled_str: StyledStr<'_> = categorised.into(); assert!(matches!( styled_str.style.get_fg_color(), Some(AColor::Ansi(AnsiColor::Blue)) @@ -206,14 +208,14 @@ mod tests { #[test] fn from_categorized_bold() { let categorised = styled_str!("Hello", Intensity:Intensity::Bold;); - let styled_str: StyledStr = categorised.into(); + let styled_str: StyledStr<'_> = categorised.into(); assert!(styled_str.style.get_effects().contains(Effects::BOLD)); } #[test] fn from_categorized_faint() { let categorised = styled_str!("Hello", Intensity:Intensity::Faint;); - let styled_str: StyledStr = categorised.into(); + let styled_str: StyledStr<'_> = categorised.into(); assert!(styled_str.style.get_effects().contains(Effects::DIMMED)); } } diff --git a/crates/anstyle-svg/CHANGELOG.md b/crates/anstyle-svg/CHANGELOG.md index f86cbfe9..d0f94199 100644 --- a/crates/anstyle-svg/CHANGELOG.md +++ b/crates/anstyle-svg/CHANGELOG.md @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] - ReleaseDate +## [0.1.4] - 2024-05-02 + +### Fixes + +- Drop MSRV to 1.65 + ## [0.1.3] - 2024-02-22 ### Fixes @@ -31,7 +37,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [0.1.0] - 2024-02-18 -[Unreleased]: https://github.com/rust-cli/anstyle/compare/anstyle-svg-v0.1.3...HEAD +[Unreleased]: https://github.com/rust-cli/anstyle/compare/anstyle-svg-v0.1.4...HEAD +[0.1.4]: https://github.com/rust-cli/anstyle/compare/anstyle-svg-v0.1.3...anstyle-svg-v0.1.4 [0.1.3]: https://github.com/rust-cli/anstyle/compare/anstyle-svg-v0.1.2...anstyle-svg-v0.1.3 [0.1.2]: https://github.com/rust-cli/anstyle/compare/anstyle-svg-v0.1.1...anstyle-svg-v0.1.2 [0.1.1]: https://github.com/rust-cli/anstyle/compare/anstyle-svg-v0.1.0...anstyle-svg-v0.1.1 diff --git a/crates/anstyle-svg/Cargo.toml b/crates/anstyle-svg/Cargo.toml index f0841686..673ae3e0 100644 --- a/crates/anstyle-svg/Cargo.toml +++ b/crates/anstyle-svg/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "anstyle-svg" -version = "0.1.3" +version = "0.1.4" description = "Convert ANSI escape codes to SVG" repository = "https://github.com/rust-cli/anstyle.git" homepage = "https://github.com/rust-cli/anstyle" @@ -12,8 +12,8 @@ rust-version.workspace = true include.workspace = true [package.metadata.docs.rs] +all-features = true rustdoc-args = ["--cfg", "docsrs"] -cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"] [package.metadata.release] pre-release-replacements = [ @@ -33,3 +33,6 @@ unicode-width = "0.1.11" [dev-dependencies] snapbox = "0.5.1" + +[lints] +workspace = true diff --git a/crates/anstyle-svg/src/lib.rs b/crates/anstyle-svg/src/lib.rs index f1ded01e..12b7f097 100644 --- a/crates/anstyle-svg/src/lib.rs +++ b/crates/anstyle-svg/src/lib.rs @@ -12,6 +12,11 @@ //! //! ![demo of supported styles](https://raw.githubusercontent.com/rust-cli/anstyle/main/crates/anstyle-svg/tests/rainbow.svg "Example output") +#![cfg_attr(docsrs, feature(doc_auto_cfg))] +#![warn(missing_docs)] +#![warn(clippy::print_stderr)] +#![warn(clippy::print_stdout)] + pub use anstyle_lossy::palette::Palette; pub use anstyle_lossy::palette::VGA; pub use anstyle_lossy::palette::WIN10_CONSOLE; @@ -29,6 +34,7 @@ pub struct Term { } impl Term { + /// Default terminal settings pub const fn new() -> Self { Self { palette: VGA, @@ -76,8 +82,12 @@ impl Term { /// **Note:** Lines are not wrapped. This is intentional as this attempts to convey the exact /// output with escape codes translated to SVG elements. pub fn render_svg(&self, ansi: &str) -> String { + use std::fmt::Write as _; use unicode_width::UnicodeWidthStr as _; + const FG: &str = "fg"; + const BG: &str = "bg"; + let mut styled = anstream::adapter::WinconBytes::new(); let mut styled = styled.extract_next(ansi.as_bytes()).collect::>(); let mut effects_in_use = anstyle::Effects::new(); @@ -93,9 +103,7 @@ impl Term { } let styled_lines = split_lines(&styled); - const FG: &str = "fg"; let fg_color = rgb_value(self.fg_color, self.palette); - const BG: &str = "bg"; let bg_color = rgb_value(self.bg_color, self.palette); let font_family = self.font_family; @@ -109,7 +117,6 @@ impl Term { let width_px = (max_width as f64 * 8.4).ceil() as usize; let width_px = std::cmp::max(width_px, self.min_width_px) + self.padding_px * 2; - use std::fmt::Write as _; let mut buffer = String::new(); writeln!( &mut buffer, @@ -259,6 +266,7 @@ const FG_COLOR: anstyle::Color = anstyle::Color::Ansi(anstyle::AnsiColor::White) const BG_COLOR: anstyle::Color = anstyle::Color::Ansi(anstyle::AnsiColor::Black); fn write_fg_span(buffer: &mut String, style: &anstyle::Style, fragment: &str) { + use std::fmt::Write as _; let fg_color = style.get_fg_color().map(|c| color_name(FG_PREFIX, c)); let underline_color = style .get_underline_color() @@ -315,7 +323,6 @@ fn write_fg_span(buffer: &mut String, style: &anstyle::Style, fragment: &str) { classes.push("hidden"); } - use std::fmt::Write as _; write!(buffer, r#" String { +fn rgb_value(color: anstyle::Color, palette: Palette) -> String { let color = anstyle_lossy::color_to_rgb(color, palette); let anstyle::RgbColor(r, g, b) = color; format!("#{r:02X}{g:02X}{b:02X}") @@ -407,7 +414,7 @@ fn color_name(prefix: &str, color: anstyle::Color) -> String { fn color_styles( styled: &[(anstyle::Style, String)], - palette: anstyle_lossy::palette::Palette, + palette: Palette, ) -> impl Iterator { let mut colors = std::collections::BTreeMap::new(); for (style, _) in styled { diff --git a/crates/anstyle-syntect/CHANGELOG.md b/crates/anstyle-syntect/CHANGELOG.md index 184bf48b..70bff724 100644 --- a/crates/anstyle-syntect/CHANGELOG.md +++ b/crates/anstyle-syntect/CHANGELOG.md @@ -7,9 +7,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] - ReleaseDate -### Compatibility +## [1.0.1] - 2024-05-02 -- Update MSRV to 1.70.0 +### Fixes + +- Drop MSRV to 1.65 ## [1.0.0] - 2023-04-13 @@ -28,7 +30,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [0.1.1] - 2022-10-13 -[Unreleased]: https://github.com/rust-cli/anstyle/compare/anstyle-syntect-v1.0.0...HEAD +[Unreleased]: https://github.com/rust-cli/anstyle/compare/anstyle-syntect-v1.0.1...HEAD +[1.0.1]: https://github.com/rust-cli/anstyle/compare/anstyle-syntect-v1.0.0...anstyle-syntect-v1.0.1 [1.0.0]: https://github.com/rust-cli/anstyle/compare/anstyle-syntect-v0.2.0...anstyle-syntect-v1.0.0 [0.2.0]: https://github.com/rust-cli/anstyle/compare/anstyle-syntect-v0.1.2...anstyle-syntect-v0.2.0 [0.1.2]: https://github.com/rust-cli/anstyle/compare/anstyle-syntect-v0.1.1...anstyle-syntect-v0.1.2 diff --git a/crates/anstyle-syntect/Cargo.toml b/crates/anstyle-syntect/Cargo.toml index 4071a483..d706c3af 100644 --- a/crates/anstyle-syntect/Cargo.toml +++ b/crates/anstyle-syntect/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "anstyle-syntect" -version = "1.0.0" +version = "1.0.1" description = "Adapt between syntect and anstyle" repository = "https://github.com/rust-cli/anstyle.git" homepage = "https://github.com/rust-cli/anstyle" @@ -11,6 +11,10 @@ edition.workspace = true rust-version.workspace = true include.workspace = true +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] + [package.metadata.release] pre-release-replacements = [ {file="CHANGELOG.md", search="Unreleased", replace="{{version}}", min=1}, @@ -20,7 +24,9 @@ pre-release-replacements = [ {file="CHANGELOG.md", search="", replace="\n[Unreleased]: https://github.com/rust-cli/anstyle/compare/{{tag_name}}...HEAD", exactly=1}, ] - [dependencies] anstyle = { version = "1.0.0", path = "../anstyle" } syntect = { version = "5.0.0", default-features = false } + +[lints] +workspace = true diff --git a/crates/anstyle-syntect/README.md b/crates/anstyle-syntect/README.md index 81d68efe..5bc2bd02 100644 --- a/crates/anstyle-syntect/README.md +++ b/crates/anstyle-syntect/README.md @@ -1,6 +1,6 @@ # anstyle-syntect -> Convert from color styling types to [`ansi_term`](https://lib.rs/syntect) color types +> Convert between [`syntect`](https://lib.rs/syntect) highlighting and generic styling types [![Documentation](https://img.shields.io/badge/docs-master-blue.svg)][Documentation] ![License](https://img.shields.io/crates/l/anstyle-syntect.svg) diff --git a/crates/anstyle-syntect/src/lib.rs b/crates/anstyle-syntect/src/lib.rs index a3fc77d7..083209a8 100644 --- a/crates/anstyle-syntect/src/lib.rs +++ b/crates/anstyle-syntect/src/lib.rs @@ -1,19 +1,12 @@ -mod sealed { - pub(crate) trait Sealed {} -} - -trait Ext: sealed::Sealed { - fn syntect_to_anstyle(self) -> anstyle::Style; -} +//! Convert between [`syntect`](https://lib.rs/syntect) highlighting and +//! [generic styling types][anstyle::Style] -impl sealed::Sealed for syntect::highlighting::Style {} - -impl Ext for syntect::highlighting::Style { - fn syntect_to_anstyle(self) -> anstyle::Style { - to_anstyle(self) - } -} +#![cfg_attr(docsrs, feature(doc_auto_cfg))] +#![warn(missing_docs)] +#![warn(clippy::print_stderr)] +#![warn(clippy::print_stdout)] +/// Convert highlighting style to general style pub fn to_anstyle(style: syntect::highlighting::Style) -> anstyle::Style { anstyle::Style::new() .fg_color(Some(to_anstyle_color(style.foreground))) @@ -21,10 +14,12 @@ pub fn to_anstyle(style: syntect::highlighting::Style) -> anstyle::Style { .effects(to_anstyle_effects(style.font_style)) } +/// Convert highlighting color to general color pub fn to_anstyle_color(color: syntect::highlighting::Color) -> anstyle::Color { anstyle::RgbColor(color.r, color.g, color.b).into() } +/// Convert highlighting style to general effects pub fn to_anstyle_effects(style: syntect::highlighting::FontStyle) -> anstyle::Effects { let mut effects = anstyle::Effects::new(); diff --git a/crates/anstyle-termcolor/CHANGELOG.md b/crates/anstyle-termcolor/CHANGELOG.md index 0288e489..8fa80d09 100644 --- a/crates/anstyle-termcolor/CHANGELOG.md +++ b/crates/anstyle-termcolor/CHANGELOG.md @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] - ReleaseDate +## [1.1.1] - 2024-05-02 + +### Fixes + +- Drop MSRV to 1.65 + ## [1.1.0] - 2023-09-12 ### Compatibility @@ -38,7 +44,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [0.1.1] - 2022-05-18 -[Unreleased]: https://github.com/rust-cli/anstyle/compare/anstyle-termcolor-v1.1.0...HEAD +[Unreleased]: https://github.com/rust-cli/anstyle/compare/anstyle-termcolor-v1.1.1...HEAD +[1.1.1]: https://github.com/rust-cli/anstyle/compare/anstyle-termcolor-v1.1.0...anstyle-termcolor-v1.1.1 [1.1.0]: https://github.com/rust-cli/anstyle/compare/anstyle-termcolor-v1.0.0...anstyle-termcolor-v1.1.0 [1.0.0]: https://github.com/rust-cli/anstyle/compare/anstyle-termcolor-v0.3.0...anstyle-termcolor-v1.0.0 [0.3.0]: https://github.com/rust-cli/anstyle/compare/anstyle-termcolor-v0.2.2...anstyle-termcolor-v0.3.0 diff --git a/crates/anstyle-termcolor/Cargo.toml b/crates/anstyle-termcolor/Cargo.toml index fee593e6..356f57d4 100644 --- a/crates/anstyle-termcolor/Cargo.toml +++ b/crates/anstyle-termcolor/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "anstyle-termcolor" -version = "1.1.0" +version = "1.1.1" description = "Adapt between termcolor and anstyle" repository = "https://github.com/rust-cli/anstyle.git" homepage = "https://github.com/rust-cli/anstyle" @@ -11,6 +11,10 @@ edition.workspace = true rust-version.workspace = true include.workspace = true +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] + [package.metadata.release] pre-release-replacements = [ {file="CHANGELOG.md", search="Unreleased", replace="{{version}}", min=1}, @@ -20,7 +24,9 @@ pre-release-replacements = [ {file="CHANGELOG.md", search="", replace="\n[Unreleased]: https://github.com/rust-cli/anstyle/compare/{{tag_name}}...HEAD", exactly=1}, ] - [dependencies] anstyle = { version = "1.0.0", path = "../anstyle" } termcolor = "1.1.3" + +[lints] +workspace = true diff --git a/crates/anstyle-termcolor/README.md b/crates/anstyle-termcolor/README.md index 2f1b7404..682b7ae9 100644 --- a/crates/anstyle-termcolor/README.md +++ b/crates/anstyle-termcolor/README.md @@ -1,6 +1,6 @@ # anstyle-termcolor -> Convert from color styling types to [termcolor](https://lib.rs/termcolor) color types +> Convert between [termcolor](https://lib.rs/termcolor) and generic styling types [![Documentation](https://img.shields.io/badge/docs-master-blue.svg)][Documentation] ![License](https://img.shields.io/crates/l/anstyle-termcolor.svg) diff --git a/crates/anstyle-termcolor/src/lib.rs b/crates/anstyle-termcolor/src/lib.rs index d99a28c2..e6b8c4b9 100644 --- a/crates/anstyle-termcolor/src/lib.rs +++ b/crates/anstyle-termcolor/src/lib.rs @@ -1,19 +1,11 @@ -mod sealed { - pub(crate) trait Sealed {} -} - -trait Ext: sealed::Sealed { - fn to_termcolor(self) -> termcolor::ColorSpec; -} +//! Convert between [termcolor](https://lib.rs/termcolor) and [generic styling types][anstyle] -impl sealed::Sealed for anstyle::Style {} - -impl Ext for anstyle::Style { - fn to_termcolor(self) -> termcolor::ColorSpec { - to_termcolor_spec(self) - } -} +#![cfg_attr(docsrs, feature(doc_auto_cfg))] +#![warn(missing_docs)] +#![warn(clippy::print_stderr)] +#![warn(clippy::print_stdout)] +/// Adapt generic styling to [`termcolor`] pub fn to_termcolor_spec(style: anstyle::Style) -> termcolor::ColorSpec { let fg = style.get_fg_color().map(to_termcolor_color); let bg = style.get_bg_color().map(to_termcolor_color); @@ -29,6 +21,7 @@ pub fn to_termcolor_spec(style: anstyle::Style) -> termcolor::ColorSpec { style } +/// Adapt generic colors to [`termcolor`] pub fn to_termcolor_color(color: anstyle::Color) -> termcolor::Color { match color { anstyle::Color::Ansi(ansi) => ansi_to_termcolor_color(ansi), diff --git a/crates/anstyle-wincon/CHANGELOG.md b/crates/anstyle-wincon/CHANGELOG.md index 2aa5ca3c..e4526784 100644 --- a/crates/anstyle-wincon/CHANGELOG.md +++ b/crates/anstyle-wincon/CHANGELOG.md @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] - ReleaseDate +## [3.0.3] - 2024-05-02 + +### Fixes + +- Drop MSRV to 1.65 + ## [3.0.2] - 2023-12-04 ## [3.0.1] - 2023-09-29 @@ -87,7 +93,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [0.0.1] - 2023-03-07 -[Unreleased]: https://github.com/rust-cli/anstyle/compare/anstyle-wincon-v3.0.2...HEAD +[Unreleased]: https://github.com/rust-cli/anstyle/compare/anstyle-wincon-v3.0.3...HEAD +[3.0.3]: https://github.com/rust-cli/anstyle/compare/anstyle-wincon-v3.0.2...anstyle-wincon-v3.0.3 [3.0.2]: https://github.com/rust-cli/anstyle/compare/anstyle-wincon-v3.0.1...anstyle-wincon-v3.0.2 [3.0.1]: https://github.com/rust-cli/anstyle/compare/anstyle-wincon-v3.0.0...anstyle-wincon-v3.0.1 [3.0.0]: https://github.com/rust-cli/anstyle/compare/anstyle-wincon-v2.1.0...anstyle-wincon-v3.0.0 diff --git a/crates/anstyle-wincon/Cargo.toml b/crates/anstyle-wincon/Cargo.toml index d5ac23c0..42894294 100644 --- a/crates/anstyle-wincon/Cargo.toml +++ b/crates/anstyle-wincon/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "anstyle-wincon" -version = "3.0.2" +version = "3.0.3" description = "Styling legacy Windows terminals" repository = "https://github.com/rust-cli/anstyle.git" homepage = "https://github.com/rust-cli/anstyle" @@ -12,8 +12,8 @@ rust-version.workspace = true include.workspace = true [package.metadata.docs.rs] +all-features = true rustdoc-args = ["--cfg", "docsrs"] -features = [] targets = ["x86_64-pc-windows-msvc"] [package.metadata.release] @@ -25,7 +25,6 @@ pre-release-replacements = [ {file="CHANGELOG.md", search="", replace="\n[Unreleased]: https://github.com/rust-cli/anstyle/compare/{{tag_name}}...HEAD", exactly=1}, ] - [dependencies] anstyle = { version = "1.0.0", path = "../anstyle" } @@ -34,3 +33,6 @@ lexopt = "0.3.0" [target.'cfg(windows)'.dependencies] windows-sys = { version = "0.52.0", features = ["Win32_System_Console", "Win32_Foundation"] } + +[lints] +workspace = true diff --git a/crates/anstyle-wincon/examples/dump-wincon.rs b/crates/anstyle-wincon/examples/dump-wincon.rs index 954ee47b..c1d4f178 100644 --- a/crates/anstyle-wincon/examples/dump-wincon.rs +++ b/crates/anstyle-wincon/examples/dump-wincon.rs @@ -1,3 +1,5 @@ +//! Write colored text using wincon API calls + use anstyle_wincon::WinconStream as _; fn main() -> Result<(), lexopt::Error> { diff --git a/crates/anstyle-wincon/examples/set-wincon.rs b/crates/anstyle-wincon/examples/set-wincon.rs index 6febb0ae..6485a505 100644 --- a/crates/anstyle-wincon/examples/set-wincon.rs +++ b/crates/anstyle-wincon/examples/set-wincon.rs @@ -1,3 +1,5 @@ +//! Interactively manipulate wincon colors + #![cfg_attr(not(windows), allow(dead_code))] #[cfg(not(windows))] diff --git a/crates/anstyle-wincon/src/lib.rs b/crates/anstyle-wincon/src/lib.rs index e04fab6e..52327b14 100644 --- a/crates/anstyle-wincon/src/lib.rs +++ b/crates/anstyle-wincon/src/lib.rs @@ -9,6 +9,9 @@ //! - More focused, smaller #![cfg_attr(docsrs, feature(doc_auto_cfg))] +#![warn(missing_docs)] +#![warn(clippy::print_stderr)] +#![warn(clippy::print_stdout)] pub mod ansi; mod stream; diff --git a/crates/anstyle-wincon/src/stream.rs b/crates/anstyle-wincon/src/stream.rs index 9f101080..cd6f18f6 100644 --- a/crates/anstyle-wincon/src/stream.rs +++ b/crates/anstyle-wincon/src/stream.rs @@ -101,9 +101,7 @@ impl WinconStream for std::io::Stderr { #[cfg(not(windows))] mod platform { - use super::*; - - impl WinconStream for std::io::StdoutLock<'_> { + impl super::WinconStream for std::io::StdoutLock<'_> { fn write_colored( &mut self, fg: Option, @@ -114,7 +112,7 @@ mod platform { } } - impl WinconStream for std::io::StderrLock<'_> { + impl super::WinconStream for std::io::StderrLock<'_> { fn write_colored( &mut self, fg: Option, @@ -128,9 +126,7 @@ mod platform { #[cfg(windows)] mod platform { - use super::*; - - impl WinconStream for std::io::StdoutLock<'_> { + impl super::WinconStream for std::io::StdoutLock<'_> { fn write_colored( &mut self, fg: Option, @@ -142,7 +138,7 @@ mod platform { } } - impl WinconStream for std::io::StderrLock<'_> { + impl super::WinconStream for std::io::StderrLock<'_> { fn write_colored( &mut self, fg: Option, diff --git a/crates/anstyle-yansi/CHANGELOG.md b/crates/anstyle-yansi/CHANGELOG.md index 685f8c14..688af9cc 100644 --- a/crates/anstyle-yansi/CHANGELOG.md +++ b/crates/anstyle-yansi/CHANGELOG.md @@ -7,9 +7,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] - ReleaseDate -### Compatibility +## [1.0.1] - 2024-05-02 -- Update MSRV to 1.70.0 +### Fixes + +- Drop MSRV to 1.65 ## [1.0.0] - 2023-04-13 @@ -32,7 +34,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [0.1.1] - 2022-05-18 -[Unreleased]: https://github.com/rust-cli/anstyle/compare/anstyle-yansi-v1.0.0...HEAD +[Unreleased]: https://github.com/rust-cli/anstyle/compare/anstyle-yansi-v1.0.1...HEAD +[1.0.1]: https://github.com/rust-cli/anstyle/compare/anstyle-yansi-v1.0.0...anstyle-yansi-v1.0.1 [1.0.0]: https://github.com/rust-cli/anstyle/compare/anstyle-yansi-v0.3.0...anstyle-yansi-v1.0.0 [0.3.0]: https://github.com/rust-cli/anstyle/compare/anstyle-yansi-v0.2.2...anstyle-yansi-v0.3.0 [0.2.2]: https://github.com/rust-cli/anstyle/compare/anstyle-yansi-v0.2.1...anstyle-yansi-v0.2.2 diff --git a/crates/anstyle-yansi/Cargo.toml b/crates/anstyle-yansi/Cargo.toml index 18b2703a..3d57b518 100644 --- a/crates/anstyle-yansi/Cargo.toml +++ b/crates/anstyle-yansi/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "anstyle-yansi" -version = "1.0.0" +version = "1.0.1" description = "Adapt between yansi and anstyle" repository = "https://github.com/rust-cli/anstyle.git" homepage = "https://github.com/rust-cli/anstyle" @@ -11,6 +11,10 @@ edition.workspace = true rust-version.workspace = true include.workspace = true +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] + [package.metadata.release] pre-release-replacements = [ {file="CHANGELOG.md", search="Unreleased", replace="{{version}}", min=1}, @@ -20,7 +24,9 @@ pre-release-replacements = [ {file="CHANGELOG.md", search="", replace="\n[Unreleased]: https://github.com/rust-cli/anstyle/compare/{{tag_name}}...HEAD", exactly=1}, ] - [dependencies] anstyle = { version = "1.0.0", path = "../anstyle" } yansi = "0.5.1" + +[lints] +workspace = true diff --git a/crates/anstyle-yansi/README.md b/crates/anstyle-yansi/README.md index 436e38ff..b5cebea7 100644 --- a/crates/anstyle-yansi/README.md +++ b/crates/anstyle-yansi/README.md @@ -1,6 +1,6 @@ # anstyle-yansi -> Convert from color styling types to [yansi](https://lib.rs/yansi) color types +> Convert between [yansi](https://lib.rs/yansi) and generic styling types [![Documentation](https://img.shields.io/badge/docs-master-blue.svg)][Documentation] ![License](https://img.shields.io/crates/l/anstyle-yansi.svg) diff --git a/crates/anstyle-yansi/src/lib.rs b/crates/anstyle-yansi/src/lib.rs index 814c0af5..2b0d254a 100644 --- a/crates/anstyle-yansi/src/lib.rs +++ b/crates/anstyle-yansi/src/lib.rs @@ -1,19 +1,11 @@ -mod sealed { - pub(crate) trait Sealed {} -} - -trait Ext: sealed::Sealed { - fn to_yansi(self) -> yansi::Style; -} +//! Convert between [yansi](https://lib.rs/yansi) and generic styling types -impl sealed::Sealed for anstyle::Style {} - -impl Ext for anstyle::Style { - fn to_yansi(self) -> yansi::Style { - to_yansi_style(self) - } -} +#![cfg_attr(docsrs, feature(doc_auto_cfg))] +#![warn(missing_docs)] +#![warn(clippy::print_stderr)] +#![warn(clippy::print_stdout)] +/// Adapt generic styling to [`yansi`] pub fn to_yansi_style(style: anstyle::Style) -> yansi::Style { let (fg, fg_bold) = style .get_fg_color() @@ -53,6 +45,7 @@ pub fn to_yansi_style(style: anstyle::Style) -> yansi::Style { style } +/// Adapt generic color to [`yansi`] pub fn to_yansi_color(color: anstyle::Color) -> yansi::Color { to_yansi_color_with_bold(color).0 } diff --git a/crates/anstyle/CHANGELOG.md b/crates/anstyle/CHANGELOG.md index 8da7b629..d888ff48 100644 --- a/crates/anstyle/CHANGELOG.md +++ b/crates/anstyle/CHANGELOG.md @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] - ReleaseDate +## [1.0.7] - 2024-05-02 + +### Fixes + +- Drop MSRV to 1.65 + ## [1.0.6] - 2024-02-05 ### Fixes @@ -162,7 +168,8 @@ MSRV updated to 1.64.0 ## [0.1.1] - 2022-05-18 -[Unreleased]: https://github.com/rust-cli/anstyle/compare/v1.0.6...HEAD +[Unreleased]: https://github.com/rust-cli/anstyle/compare/v1.0.7...HEAD +[1.0.7]: https://github.com/rust-cli/anstyle/compare/v1.0.6...v1.0.7 [1.0.6]: https://github.com/rust-cli/anstyle/compare/v1.0.5...v1.0.6 [1.0.5]: https://github.com/rust-cli/anstyle/compare/v1.0.4...v1.0.5 [1.0.4]: https://github.com/rust-cli/anstyle/compare/v1.0.3...v1.0.4 diff --git a/crates/anstyle/Cargo.toml b/crates/anstyle/Cargo.toml index 1fb97b9a..406f207b 100644 --- a/crates/anstyle/Cargo.toml +++ b/crates/anstyle/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "anstyle" -version = "1.0.6" +version = "1.0.7" description = "ANSI text styling" repository = "https://github.com/rust-cli/anstyle.git" homepage = "https://github.com/rust-cli/anstyle" @@ -11,6 +11,10 @@ edition.workspace = true rust-version.workspace = true include.workspace = true +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] + [package.metadata.release] tag-prefix = "" pre-release-replacements = [ @@ -29,3 +33,6 @@ std = [] [dev-dependencies] lexopt = "0.3.0" + +[lints] +workspace = true diff --git a/crates/anstyle/examples/dump-style.rs b/crates/anstyle/examples/dump-style.rs index 2a5a37d1..2e539eb6 100644 --- a/crates/anstyle/examples/dump-style.rs +++ b/crates/anstyle/examples/dump-style.rs @@ -1,3 +1,5 @@ +//! Write ANSI escape code colored text + use std::io::Write; fn main() -> Result<(), lexopt::Error> { @@ -6,7 +8,9 @@ fn main() -> Result<(), lexopt::Error> { let mut stdout = stdout.lock(); for fixed in 0..16 { - let color = anstyle::Ansi256Color(fixed).into_ansi().unwrap(); + let color = anstyle::Ansi256Color(fixed) + .into_ansi() + .expect("4-bit range used"); let style = style(color, args.layer, args.effects); let _ = print_number(&mut stdout, fixed, style); if fixed == 7 || fixed == 15 { diff --git a/crates/anstyle/src/color.rs b/crates/anstyle/src/color.rs index 797d4b54..a9aafb5a 100644 --- a/crates/anstyle/src/color.rs +++ b/crates/anstyle/src/color.rs @@ -1,8 +1,18 @@ /// Any ANSI color code scheme +#[allow(clippy::exhaustive_enums)] #[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] pub enum Color { + /// Available 4-bit ANSI color palette codes + /// + /// The user's terminal defines the meaning of the each palette code. Ansi(AnsiColor), + /// 256 (8-bit) color support + /// + /// - `0..16` are [`AnsiColor`] palette codes + /// - `0..232` map to [`RgbColor`] color values + /// - `232..` map to [`RgbColor`] gray-scale values Ansi256(Ansi256Color), + /// 24-bit ANSI RGB color codes Rgb(RgbColor), } @@ -23,7 +33,7 @@ impl Color { /// Render the ANSI code for a foreground color #[inline] - pub fn render_fg(self) -> impl core::fmt::Display + Copy + Clone { + pub fn render_fg(self) -> impl core::fmt::Display + Copy { match self { Self::Ansi(color) => color.as_fg_buffer(), Self::Ansi256(color) => color.as_fg_buffer(), @@ -44,7 +54,7 @@ impl Color { /// Render the ANSI code for a background color #[inline] - pub fn render_bg(self) -> impl core::fmt::Display + Copy + Clone { + pub fn render_bg(self) -> impl core::fmt::Display + Copy { match self { Self::Ansi(color) => color.as_bg_buffer(), Self::Ansi256(color) => color.as_bg_buffer(), @@ -64,7 +74,7 @@ impl Color { } #[inline] - pub(crate) fn render_underline(self) -> impl core::fmt::Display + Copy + Clone { + pub(crate) fn render_underline(self) -> impl core::fmt::Display + Copy { match self { Self::Ansi(color) => color.as_underline_buffer(), Self::Ansi256(color) => color.as_underline_buffer(), @@ -122,6 +132,7 @@ impl From<(u8, u8, u8)> for Color { /// Available 4-bit ANSI color palette codes /// /// The user's terminal defines the meaning of the each palette code. +#[allow(clippy::exhaustive_enums)] #[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] #[repr(u8)] pub enum AnsiColor { @@ -191,7 +202,7 @@ impl AnsiColor { /// Render the ANSI code for a foreground color #[inline] - pub fn render_fg(self) -> impl core::fmt::Display + Copy + Clone { + pub fn render_fg(self) -> impl core::fmt::Display + Copy { NullFormatter(self.as_fg_str()) } @@ -224,7 +235,7 @@ impl AnsiColor { /// Render the ANSI code for a background color #[inline] - pub fn render_bg(self) -> impl core::fmt::Display + Copy + Clone { + pub fn render_bg(self) -> impl core::fmt::Display + Copy { NullFormatter(self.as_bg_str()) } @@ -335,6 +346,7 @@ impl AnsiColor { /// - `0..16` are [`AnsiColor`] palette codes /// - `0..232` map to [`RgbColor`] color values /// - `232..` map to [`RgbColor`] gray-scale values +#[allow(clippy::exhaustive_structs)] #[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] #[repr(transparent)] pub struct Ansi256Color(pub u8); @@ -354,11 +366,13 @@ impl Ansi256Color { crate::Style::new().fg_color(Some(Color::Ansi256(self))) } + /// Get the raw value #[inline] pub const fn index(self) -> u8 { self.0 } + /// Convert to [`AnsiColor`] when there is a 1:1 mapping #[inline] pub const fn into_ansi(self) -> Option { match self.index() { @@ -382,6 +396,7 @@ impl Ansi256Color { } } + /// Losslessly convert from [`AnsiColor`] #[inline] pub const fn from_ansi(color: AnsiColor) -> Self { match color { @@ -406,7 +421,7 @@ impl Ansi256Color { /// Render the ANSI code for a foreground color #[inline] - pub fn render_fg(self) -> impl core::fmt::Display + Copy + Clone { + pub fn render_fg(self) -> impl core::fmt::Display + Copy { self.as_fg_buffer() } @@ -420,7 +435,7 @@ impl Ansi256Color { /// Render the ANSI code for a background color #[inline] - pub fn render_bg(self) -> impl core::fmt::Display + Copy + Clone { + pub fn render_bg(self) -> impl core::fmt::Display + Copy { self.as_bg_buffer() } @@ -456,6 +471,7 @@ impl From for Ansi256Color { } /// 24-bit ANSI RGB color codes +#[allow(clippy::exhaustive_structs)] #[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct RgbColor(pub u8, pub u8, pub u8); @@ -474,16 +490,19 @@ impl RgbColor { crate::Style::new().fg_color(Some(Color::Rgb(self))) } + /// Red #[inline] pub const fn r(self) -> u8 { self.0 } + /// Green #[inline] pub const fn g(self) -> u8 { self.1 } + /// Blue #[inline] pub const fn b(self) -> u8 { self.2 @@ -491,7 +510,7 @@ impl RgbColor { /// Render the ANSI code for a foreground color #[inline] - pub fn render_fg(self) -> impl core::fmt::Display + Copy + Clone { + pub fn render_fg(self) -> impl core::fmt::Display + Copy { self.as_fg_buffer() } @@ -509,7 +528,7 @@ impl RgbColor { /// Render the ANSI code for a background color #[inline] - pub fn render_bg(self) -> impl core::fmt::Display + Copy + Clone { + pub fn render_bg(self) -> impl core::fmt::Display + Copy { self.as_bg_buffer() } @@ -592,7 +611,10 @@ impl DisplayBuffer { #[inline] fn as_str(&self) -> &str { // SAFETY: Only `&str` can be written to the buffer - unsafe { core::str::from_utf8_unchecked(&self.buffer[0..self.len]) } + #[allow(unsafe_code)] + unsafe { + core::str::from_utf8_unchecked(&self.buffer[0..self.len]) + } } #[inline] diff --git a/crates/anstyle/src/effect.rs b/crates/anstyle/src/effect.rs index f782776c..1a80fa3e 100644 --- a/crates/anstyle/src/effect.rs +++ b/crates/anstyle/src/effect.rs @@ -9,21 +9,30 @@ pub struct Effects(u16); impl Effects { + /// No [`Effects`] applied const PLAIN: Self = Effects(0); + #[allow(missing_docs)] pub const BOLD: Self = Effects(1 << 0); + #[allow(missing_docs)] pub const DIMMED: Self = Effects(1 << 1); /// Not widely supported. Sometimes treated as inverse or blink pub const ITALIC: Self = Effects(1 << 2); /// Style extensions exist for Kitty, VTE, mintty and iTerm2. pub const UNDERLINE: Self = Effects(1 << 3); + #[allow(missing_docs)] pub const DOUBLE_UNDERLINE: Self = Effects(1 << 4); + #[allow(missing_docs)] pub const CURLY_UNDERLINE: Self = Effects(1 << 5); + #[allow(missing_docs)] pub const DOTTED_UNDERLINE: Self = Effects(1 << 6); + #[allow(missing_docs)] pub const DASHED_UNDERLINE: Self = Effects(1 << 7); + #[allow(missing_docs)] pub const BLINK: Self = Effects(1 << 8); /// Swap foreground and background colors; inconsistent emulation pub const INVERT: Self = Effects(1 << 9); + #[allow(missing_docs)] pub const HIDDEN: Self = Effects(1 << 10); /// Characters legible but marked as if for deletion. Not supported in Terminal.app pub const STRIKETHROUGH: Self = Effects(1 << 11); @@ -156,7 +165,7 @@ impl Effects { /// Render the ANSI code #[inline] - pub fn render(self) -> impl core::fmt::Display + Copy + Clone { + pub fn render(self) -> impl core::fmt::Display + Copy { EffectsDisplay(self) } @@ -321,6 +330,7 @@ impl core::fmt::Display for EffectsDisplay { } } +/// Enumerate each enabled value in [`Effects`] #[derive(Clone, Debug, PartialEq, Eq)] pub struct EffectIter { index: usize, diff --git a/crates/anstyle/src/lib.rs b/crates/anstyle/src/lib.rs index 41b7174e..3ce6a842 100644 --- a/crates/anstyle/src/lib.rs +++ b/crates/anstyle/src/lib.rs @@ -25,11 +25,12 @@ //! //! User-styling parsers: //! - [anstyle-git](https://docs.rs/anstyle-git): Parse Git style descriptions -//! - [anstyle-ls](https://docs.rs/anstyle-ls): Parse LS_COLORS style descriptions +//! - [anstyle-ls](https://docs.rs/anstyle-ls): Parse `LS_COLORS` style descriptions //! //! Convert to other formats //! - [anstream](https://docs.rs/anstream): A simple cross platform library for writing colored text to a terminal //! - [anstyle-roff](https://docs.rs/anstyle-roff): For converting to ROFF +//! - [anstyle-syntect](https://docs.rs/anstyle-syntect): For working with syntax highlighting //! //! Utilities //! - [anstyle-lossy](https://docs.rs/anstyle-lossy): Convert between `anstyle::Color` types @@ -44,6 +45,10 @@ //! ``` #![cfg_attr(not(feature = "std"), no_std)] +#![cfg_attr(docsrs, feature(doc_auto_cfg))] +#![warn(missing_docs)] +#![warn(clippy::print_stderr)] +#![warn(clippy::print_stdout)] #[macro_use] mod macros; diff --git a/crates/anstyle/src/reset.rs b/crates/anstyle/src/reset.rs index f35b8d95..62c8b4bc 100644 --- a/crates/anstyle/src/reset.rs +++ b/crates/anstyle/src/reset.rs @@ -1,4 +1,5 @@ /// Reset terminal formatting +#[allow(clippy::exhaustive_structs)] #[derive(Copy, Clone, Default, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct Reset; @@ -7,7 +8,7 @@ impl Reset { /// /// `Reset` also implements `Display` directly, so calling this method is optional. #[inline] - pub fn render(self) -> impl core::fmt::Display + Copy + Clone { + pub fn render(self) -> impl core::fmt::Display + Copy { self } } diff --git a/crates/anstyle/src/style.rs b/crates/anstyle/src/style.rs index 2e93b41b..cfa80858 100644 --- a/crates/anstyle/src/style.rs +++ b/crates/anstyle/src/style.rs @@ -101,7 +101,7 @@ impl Style { /// /// `Style` also implements `Display` directly, so calling this method is optional. #[inline] - pub fn render(self) -> impl core::fmt::Display + Copy + Clone { + pub fn render(self) -> impl core::fmt::Display + Copy { StyleDisplay(self) } @@ -150,7 +150,7 @@ impl Style { /// /// Unlike [`Reset::render`][crate::Reset::render], this will elide the code if there is nothing to reset. #[inline] - pub fn render_reset(self) -> impl core::fmt::Display + Copy + Clone { + pub fn render_reset(self) -> impl core::fmt::Display + Copy { if self != Self::new() { RESET } else { @@ -289,27 +289,32 @@ impl Style { /// # Reflection impl Style { + /// Get the foreground color #[inline] pub const fn get_fg_color(self) -> Option { self.fg } + /// Get the background color #[inline] + #[allow(missing_docs)] pub const fn get_bg_color(self) -> Option { self.bg } #[inline] + #[allow(missing_docs)] pub const fn get_underline_color(self) -> Option { self.underline } #[inline] + #[allow(missing_docs)] pub const fn get_effects(self) -> crate::Effects { self.effects } - /// Check if no effects are enabled + /// Check if no styling is enabled #[inline] pub const fn is_plain(self) -> bool { self.fg.is_none() @@ -395,7 +400,7 @@ impl core::ops::SubAssign for Style { /// assert_ne!(anstyle::Effects::UNDERLINE | effects, effects); /// assert_ne!(anstyle::RgbColor(0, 0, 0).on_default() | effects, effects); /// ``` -impl core::cmp::PartialEq for Style { +impl PartialEq for Style { #[inline] fn eq(&self, other: &crate::Effects) -> bool { let other = Self::from(*other); @@ -424,6 +429,7 @@ impl core::fmt::Display for StyleDisplay { } #[test] +#[cfg(feature = "std")] fn print_size_of() { use std::mem::size_of; dbg!(size_of::