From 8822fd5e88fd9e9bde2bdda79a8b1e4ad84dd166 Mon Sep 17 00:00:00 2001 From: Sebastien Rousseau Date: Thu, 9 May 2024 21:40:10 +0100 Subject: [PATCH 1/7] v0.0.4 --- .cargo/config.toml | 2 - .github/workflows/audit.yml | 13 +- .github/workflows/check.yml | 7 +- .github/workflows/coverage.yml | 61 +++++ .github/workflows/document.yml | 12 +- .github/workflows/lint.yml | 6 +- .github/workflows/release.yml | 201 +++----------- .github/workflows/test.yml | 35 +-- Cargo.lock | 474 +++------------------------------ Cargo.toml | 111 ++++++-- README.md | 6 +- TEMPLATE.md | 4 +- benches/criterion.rs | 3 +- src/lib.rs | 13 +- tests/test_constants.rs | 1 - tests/test_lib.rs | 1 - tests/test_macros.rs | 5 +- tests/test_words.rs | 4 +- 18 files changed, 258 insertions(+), 701 deletions(-) delete mode 100644 .cargo/config.toml create mode 100644 .github/workflows/coverage.yml diff --git a/.cargo/config.toml b/.cargo/config.toml deleted file mode 100644 index 3f72aba..0000000 --- a/.cargo/config.toml +++ /dev/null @@ -1,2 +0,0 @@ -[alias] -xtask = "run --package xtask --bin xtask --" \ No newline at end of file diff --git a/.github/workflows/audit.yml b/.github/workflows/audit.yml index efbedcb..e5a68fb 100644 --- a/.github/workflows/audit.yml +++ b/.github/workflows/audit.yml @@ -3,6 +3,7 @@ name: πŸ§ͺ Audit on: push: branches: + - main - feat/cmn pull_request: branches: @@ -15,9 +16,13 @@ jobs: name: Audit dependencies runs-on: ubuntu-latest steps: - - uses: hecrj/setup-rust-action@v1 + - uses: hecrj/setup-rust-action@v2 - name: Install cargo-audit run: cargo install cargo-audit - - uses: actions/checkout@master - - name: Audit dependencies - run: cargo audit + + - uses: actions/checkout@v4 + - name: Resolve dependencies + run: cargo update + + - name: Audit vulnerabilities + run: cargo audit \ No newline at end of file diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 263b9a2..5c35532 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -3,6 +3,7 @@ name: πŸ§ͺ Check on: push: branches: + - main - feat/cmn pull_request: branches: @@ -15,9 +16,9 @@ jobs: name: Check runs-on: ubuntu-latest steps: - - uses: hecrj/setup-rust-action@v1 + - uses: hecrj/setup-rust-action@v2 with: components: clippy - - uses: actions/checkout@master + - uses: actions/checkout@v4 - name: Check lints - run: cargo check --all-targets --workspace --all-features + run: cargo check --all-targets --workspace --all-features \ No newline at end of file diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml new file mode 100644 index 0000000..ea5a28f --- /dev/null +++ b/.github/workflows/coverage.yml @@ -0,0 +1,61 @@ +name: πŸ“Ά Coverage + +on: + push: + branches: + - main + pull_request: + +env: + CARGO_TERM_COLOR: always + +jobs: + coverage: + name: Code Coverage + runs-on: ubuntu-latest + env: + CARGO_INCREMENTAL: "0" + RUSTFLAGS: "-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests" + RUSTDOCFLAGS: "-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests" + + steps: + # Checkout the repository + - name: Checkout repository + uses: actions/checkout@v4 + + # Setup Rust nightly + - name: Install Rust + uses: actions-rs/toolchain@v1 + id: toolchain + with: + toolchain: nightly + override: true + + # Configure cache for Cargo + - name: Cache Cargo registry, index + uses: actions/cache@v4 + id: cache-cargo + with: + path: | + ~/.cargo/registry + ~/.cargo/bin + ~/.cargo/git + key: linux-${{ steps.toolchain.outputs.rustc_hash }}-rust-cov-${{ hashFiles('**/Cargo.lock') }} + + # Run tests with all features + - name: Test (cargo test) + uses: actions-rs/cargo@v1 + with: + command: test + args: "--workspace" + + # Install grcov + - uses: actions-rs/grcov@v0.1 + id: coverage + + # Upload to Codecov.io + - name: Upload to Codecov.io + uses: codecov/codecov-action@v4 + with: + token: ${{ secrets.CODECOV_TOKEN }} + file: ${{ steps.coverage.outputs.report }} \ No newline at end of file diff --git a/.github/workflows/document.yml b/.github/workflows/document.yml index e31c03c..1fb674d 100644 --- a/.github/workflows/document.yml +++ b/.github/workflows/document.yml @@ -7,6 +7,8 @@ on: pull_request: branches: - main + release: + types: [created] jobs: all: @@ -16,11 +18,11 @@ jobs: concurrency: group: ${{ github.workflow }}-${{ github.ref }} steps: - - uses: hecrj/setup-rust-action@v1 + - uses: hecrj/setup-rust-action@v2 with: rust-version: nightly - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Update libssl run: | @@ -35,7 +37,7 @@ jobs: echo '' > ./target/doc/index.html - name: Deploy - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: documentation path: target/doc @@ -43,10 +45,10 @@ jobs: retention-days: 1 - name: Write CNAME file - run: echo 'doc.cmnlib.one' > ./target/doc/CNAME + run: echo 'doc.cmnlib.com' > ./target/doc/CNAME - name: Deploy to GitHub Pages - uses: peaceiris/actions-gh-pages@v3.9.3 + uses: peaceiris/actions-gh-pages@v4 with: cname: true commit_message: Deploy documentation at ${{ github.sha }} diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 45ceff6..e81b388 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -15,9 +15,9 @@ jobs: name: Lint runs-on: ubuntu-latest steps: - - uses: hecrj/setup-rust-action@v1 + - uses: hecrj/setup-rust-action@v2 with: components: clippy - - uses: actions/checkout@master + - uses: actions/checkout@v4 - name: Check lints - run: cargo clippy --workspace --all-features --all-targets --no-deps -- -D warnings + run: cargo clippy --workspace --all-features --all-targets --no-deps -- -D warnings \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d9dd1a3..5a9bd73 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,6 +1,19 @@ name: πŸ§ͺ Release -on: [push, pull_request] +on: + push: + branches: + - main + - feat/cmn + pull_request: + branches: + - feat/cmn + release: + types: [created] + +concurrency: + group: ${{ github.ref }} + cancel-in-progress: true jobs: # Build the project for all the targets and generate artifacts. @@ -17,140 +30,31 @@ jobs: BUILD_ID: ${{ github.run_id }} CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_API_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - OS: ${{ matrix.os }} - TARGET: ${{ matrix.target }} + OS: ${{ matrix.platform.os }} + TARGET: ${{ matrix.platform.target }} strategy: fail-fast: false matrix: - target: - # List of targets: - # https://doc.rust-lang.org/nightly/rustc/platform-support.html - - # Tier 1 platforms πŸ† - - aarch64-unknown-linux-gnu # 64-bit Linux systems on ARM architecture - - i686-pc-windows-gnu # 32-bit Windows (i686-pc-windows-gnu) - - i686-pc-windows-msvc # 32-bit Windows (i686-pc-windows-msvc) - - i686-unknown-linux-gnu # 32-bit Linux (kernel 3.2+, glibc 2.17+) - - x86_64-apple-darwin # 64-bit macOS (10.7 Lion or later) - - x86_64-pc-windows-gnu # 64-bit Windows (x86_64-pc-windows-gnu) - - x86_64-pc-windows-msvc # 64-bit Windows (x86_64-pc-windows-msvc) - - x86_64-unknown-linux-gnu # 64-bit Linux (kernel 2.6.32+, glibc 2.11+) - - # Tier 2 platforms πŸ₯ˆ - - aarch64-apple-darwin # 64-bit macOS on Apple Silicon - - aarch64-pc-windows-msvc # 64-bit Windows (aarch64-pc-windows-msvc) - - aarch64-unknown-linux-musl # 64-bit Linux systems on ARM architecture - - arm-unknown-linux-gnueabi # ARMv6 Linux (kernel 3.2, glibc 2.17) - - arm-unknown-linux-gnueabihf # ARMv7 Linux, hardfloat (kernel 3.2, glibc 2.17) - - armv7-unknown-linux-gnueabihf # ARMv7 Linux, hardfloat (kernel 3.2, glibc 2.17) - - mips-unknown-linux-gnu # MIPS Linux (kernel 3.2, glibc 2.17) - - mips64-unknown-linux-gnuabi64 # MIPS64 Linux (kernel 3.2, glibc 2.17) - - mips64el-unknown-linux-gnuabi64 # MIPS64el Linux (kernel 3.2, glibc 2.17) - - mipsel-unknown-linux-gnu # MIPSel Linux (kernel 3.2, glibc 2.17) - - powerpc-unknown-linux-gnu # PowerPC Linux (kernel 3.2, glibc 2.17) - - powerpc64-unknown-linux-gnu # PowerPC64 Linux (kernel 3.2, glibc 2.17) - - powerpc64le-unknown-linux-gnu # PowerPC64le Linux (kernel 3.2, glibc 2.17) - - riscv64gc-unknown-linux-gnu # RISC-V Linux (kernel 3.2, glibc 2.17) - - s390x-unknown-linux-gnu # s390x Linux (kernel 3.2, glibc 2.17) - - x86_64-unknown-freebsd # 64-bit FreeBSD on x86-64 - # # - x86_64-unknown-illumos # 64-bit Illumos on x86-64 - - x86_64-unknown-linux-musl # 64-bit Linux (kernel 2.6.32+, musl libc) - - x86_64-unknown-netbsd # 64-bit NetBSD on x86-64 - - include: - # Tier 1 platforms πŸ† - - target: aarch64-unknown-linux-gnu - os: ubuntu-latest - cross: true - - target: i686-pc-windows-gnu - os: ubuntu-latest - cross: true - - target: i686-pc-windows-msvc + platform: + - target: x86_64-pc-windows-msvc + os: windows-latest + - target: aarch64-pc-windows-msvc os: windows-latest - cross: true - - target: i686-unknown-linux-gnu - os: ubuntu-latest - cross: true - target: x86_64-apple-darwin os: macos-latest - cross: true - - target: x86_64-pc-windows-gnu - os: ubuntu-latest - cross: true - - target: x86_64-pc-windows-msvc - os: windows-latest - cross: true - - target: x86_64-unknown-linux-gnu - os: ubuntu-latest - cross: true - - # Tier 2 platforms πŸ₯ˆ - target: aarch64-apple-darwin os: macos-latest - cross: true - - target: aarch64-pc-windows-msvc - os: windows-latest - cross: true - - target: aarch64-unknown-linux-musl - os: ubuntu-latest - cross: true - - target: arm-unknown-linux-gnueabi - os: ubuntu-latest - cross: true - - target: arm-unknown-linux-gnueabihf - os: ubuntu-latest - cross: true - - target: armv7-unknown-linux-gnueabihf - os: ubuntu-latest - cross: true - - target: mips-unknown-linux-gnu - os: ubuntu-latest - cross: true - - target: mips64-unknown-linux-gnuabi64 - os: ubuntu-latest - cross: true - - target: mips64el-unknown-linux-gnuabi64 - os: ubuntu-latest - cross: true - - target: mipsel-unknown-linux-gnu - os: ubuntu-latest - cross: true - - target: powerpc-unknown-linux-gnu - os: ubuntu-latest - cross: true - - target: powerpc64-unknown-linux-gnu - os: ubuntu-latest - cross: true - - target: powerpc64le-unknown-linux-gnu - os: ubuntu-latest - cross: true - - target: riscv64gc-unknown-linux-gnu - os: ubuntu-latest - cross: true - - target: s390x-unknown-linux-gnu - os: ubuntu-latest - cross: true - - target: x86_64-unknown-freebsd - os: ubuntu-latest - cross: true - # - target: x86_64-unknown-illumos - # os: ubuntu-latest - # cross: true - - target: x86_64-unknown-linux-musl - os: ubuntu-latest - cross: true - - target: x86_64-unknown-netbsd + - target: x86_64-unknown-linux-gnu os: ubuntu-latest - cross: true - runs-on: ${{ matrix.os }} + runs-on: ${{ matrix.platform.os }} steps: # Check out the repository code. - name: Checkout sources id: checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 # Install the stable Rust toolchain. - name: Install stable toolchain @@ -160,40 +64,25 @@ jobs: toolchain: stable override: true - # Install the targets for the cross-compilation toolchain - - name: Install target - id: install-target - run: rustup target add ${{ env.TARGET }} - - - name: Install Cross and clean artifacts - run: | - # Install cross - cargo install cross - - # Clean the build artifacts - cargo clean --verbose - shell: bash - # Cache dependencies to speed up subsequent builds. - name: Cache dependencies id: cache-dependencies - uses: actions/cache@v3 + uses: actions/cache@v4 with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - target/ - key: release-${{ runner.os }}-cargo-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }} + path: ~/.cargo + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} restore-keys: ${{ runner.os }}-cargo- + # Install the targets for the cross-compilation toolchain + - name: Install target + id: install-target + run: rustup target add ${{ env.TARGET }} + # Build the targets - name: Build targets id: build-targets uses: actions-rs/cargo@v1 with: - use-cross: true command: build args: --verbose --workspace --release --target ${{ env.TARGET }} @@ -201,17 +90,14 @@ jobs: - name: Package the binary id: package-binary run: | - if [[ ! -d "target/package" ]]; then - mkdir -p target/package - fi + mkdir -p target/package tar czf target/package/${{ env.TARGET }}.tar.gz -C target/${{ env.TARGET }}/release . echo "${{ env.TARGET }}.tar.gz=target/package/${{ env.TARGET }}.tar.gz" >> $GITHUB_ENV - shell: bash # Upload the binary for each target - name: Upload the binary id: upload-binary - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: ${{ env.TARGET }}.tar.gz path: target/package/${{ env.TARGET }}.tar.gz @@ -220,16 +106,16 @@ jobs: release: name: ❯ Release πŸš€ if: github.ref == 'refs/heads/main' && github.event_name == 'push' - needs: [build] + needs: build runs-on: ubuntu-latest steps: # Check out the repository code - name: Checkout sources - uses: actions/checkout@v3 + uses: actions/checkout@v4 # Install the stable Rust toolchain - name: Install stable toolchain - uses: actions-rs/toolchain@v1.0.6 + uses: actions-rs/toolchain@v1 with: toolchain: stable override: true @@ -243,7 +129,7 @@ jobs: # Cache dependencies to speed up subsequent builds - name: Cache dependencies - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ~/.cargo key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} @@ -256,6 +142,7 @@ jobs: echo "Downloading $target artifact" name="${target}.tar.gz" echo "Artifact name: $name" + mkdir -p target/package curl -sSL -H "Authorization: token ${GITHUB_TOKEN}" -H "Accept: application/vnd.github.v3+json" -L "${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/actions/runs/${BUILD_ID}/artifacts/${name}" -o "target/package/${name}" done @@ -314,18 +201,18 @@ jobs: crate: name: ❯ Crate.io πŸ¦€ if: github.ref == 'refs/heads/main' && github.event_name == 'push' - needs: [release] + needs: release runs-on: ubuntu-latest steps: # Check out the repository code - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 # Install the stable Rust toolchain - name: Install stable toolchain id: install-toolchain - uses: actions-rs/toolchain@v1.0.6 + uses: actions-rs/toolchain@v1 with: toolchain: stable override: true @@ -333,7 +220,7 @@ jobs: # Cache dependencies to speed up subsequent builds - name: Cache dependencies id: cache-dependencies - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: /home/runner/.cargo/registry/index/ key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }} @@ -355,10 +242,10 @@ jobs: # Publish the Rust library to Crate.io - name: Publish Library to Crate.io id: publish-library - uses: actions-rs/cargo@v1.0.1 + uses: actions-rs/cargo@v1 env: CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_API_TOKEN }} with: command: publish args: "--no-verify --allow-dirty" - use-cross: false + use-cross: false \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8a52e9f..fe897a5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -14,7 +14,7 @@ jobs: steps: # Checkout the repository - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 # Setup Rust - name: Setup Rust @@ -24,7 +24,7 @@ jobs: # Configure cache - name: Configure cache - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: | ~/.cargo/bin/ @@ -37,33 +37,4 @@ jobs: # Run tests with all features - name: Run tests with all features id: run-tests-all-features - run: cargo test --verbose --workspace --all-features - - # Install grcov - - name: Install grcov - # Only run this job on the main branch when a commit is pushed. - if: github.ref == 'refs/heads/main' && github.event_name == 'push' - id: install-grcov - run: | - mkdir -p "${HOME}/.local/bin" - curl -sL https://github.com/mozilla/grcov/releases/download/v0.8.18/grcov-x86_64-unknown-linux-gnu.tar.bz2 | tar jxf - -C "${HOME}/.local/bin" - echo "$HOME/.local/bin" >> $GITHUB_PATH - - # Use grcov to generate a coverage report - - name: Generate coverage report - # Only run this job on the main branch when a commit is pushed. - if: github.ref == 'refs/heads/main' && github.event_name == 'push' - id: generate-code-coverage - uses: actions-rs/cargo@v1.0.1 - with: - command: xtask - args: coverage - - # Upload the coverage report to codecov - - name: Upload coverage report to codecov - # Only run this job on the main branch when a commit is pushed. - if: github.ref == 'refs/heads/main' && github.event_name == 'push' - id: upload-report-codecov - uses: codecov/codecov-action@v3 - with: - files: coverage/*.lcov + run: cargo test --verbose --workspace --all-features \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index 61f3819..fba6613 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -14,17 +14,11 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "41ed9a86bf92ae6580e0a31281f65a1b1d867c0cc68d5346e2ae128dddfa6a7d" -[[package]] -name = "anyhow" -version = "1.0.71" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c7d0618f0e0b7e8ff11427422b64564d5fb0be1940354bfe2e0529b18a9d9b8" - [[package]] name = "assert_cmd" -version = "2.0.11" +version = "2.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86d6b683edf8d1119fe420a94f8a7e389239666aa72e65495d91c00462510151" +checksum = "ed72493ac66d5804837f480ab3766c72bdfab91a65e565fc54fa9e42db0073a8" dependencies = [ "anstyle", "bstr", @@ -35,17 +29,6 @@ dependencies = [ "wait-timeout", ] -[[package]] -name = "atty" -version = "0.2.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" -dependencies = [ - "hermit-abi 0.1.19", - "libc", - "winapi", -] - [[package]] name = "autocfg" version = "1.1.0" @@ -121,21 +104,6 @@ dependencies = [ "half", ] -[[package]] -name = "clap" -version = "3.2.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71655c45cb9845d3270c9d6df84ebe72b4dad3c2ba3f7023ad47c144e4e473a5" -dependencies = [ - "atty", - "bitflags", - "clap_lex 0.2.4", - "indexmap", - "strsim", - "termcolor", - "textwrap", -] - [[package]] name = "clap" version = "4.3.0" @@ -153,16 +121,7 @@ checksum = "4f423e341edefb78c9caba2d9c7f7687d0e72e89df3ce3394554754393ac3990" dependencies = [ "anstyle", "bitflags", - "clap_lex 0.5.0", -] - -[[package]] -name = "clap_lex" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5" -dependencies = [ - "os_str_bytes", + "clap_lex", ] [[package]] @@ -173,7 +132,7 @@ checksum = "2da6da31387c7e4ef160ffab6d5e7f00c42626fe39aea70a7b0f1773f7dd6c1b" [[package]] name = "cmn" -version = "0.0.3" +version = "0.0.4" dependencies = [ "assert_cmd", "criterion", @@ -181,19 +140,6 @@ dependencies = [ "serde_json", ] -[[package]] -name = "console" -version = "0.15.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3d79fbe8970a77e3e34151cc13d3b3e248aa0faaecb9f6091fa07ebefe5ad60" -dependencies = [ - "encode_unicode", - "lazy_static", - "libc", - "unicode-width", - "windows-sys 0.42.0", -] - [[package]] name = "criterion" version = "0.5.1" @@ -203,7 +149,7 @@ dependencies = [ "anes", "cast", "ciborium", - "clap 4.3.0", + "clap", "criterion-plot", "is-terminal", "itertools", @@ -273,84 +219,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "darling" -version = "0.14.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b750cb3417fd1b327431a470f388520309479ab0bf5e323505daf0290cd3850" -dependencies = [ - "darling_core", - "darling_macro", -] - -[[package]] -name = "darling_core" -version = "0.14.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "109c1ca6e6b7f82cc233a97004ea8ed7ca123a9af07a8230878fcfda9b158bf0" -dependencies = [ - "fnv", - "ident_case", - "proc-macro2", - "quote", - "strsim", - "syn 1.0.107", -] - -[[package]] -name = "darling_macro" -version = "0.14.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4aab4dbc9f7611d8b55048a3a16d2d010c2c8334e46304b40ac1cc14bf3b48e" -dependencies = [ - "darling_core", - "quote", - "syn 1.0.107", -] - -[[package]] -name = "derive_builder" -version = "0.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d67778784b508018359cbc8696edb3db78160bab2c2a28ba7f56ef6932997f8" -dependencies = [ - "derive_builder_macro", -] - -[[package]] -name = "derive_builder_core" -version = "0.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c11bdc11a0c47bc7d37d582b5285da6849c96681023680b906673c5707af7b0f" -dependencies = [ - "darling", - "proc-macro2", - "quote", - "syn 1.0.107", -] - -[[package]] -name = "derive_builder_macro" -version = "0.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebcda35c7a396850a55ffeac740804b40ffec779b98fffbb1738f4033f0ee79e" -dependencies = [ - "derive_builder_core", - "syn 1.0.107", -] - -[[package]] -name = "dialoguer" -version = "0.10.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59c6f2989294b9a498d3ad5491a79c6deb604617378e1cdc4bfc1c1361fe2f87" -dependencies = [ - "console", - "shell-words", - "tempfile", - "zeroize", -] - [[package]] name = "difflib" version = "0.4.0" @@ -363,30 +231,12 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" -[[package]] -name = "duct" -version = "0.13.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37ae3fc31835f74c2a7ceda3aeede378b0ae2e74c8f1c36559fcc9ae2a4e7d3e" -dependencies = [ - "libc", - "once_cell", - "os_pipe", - "shared_child", -] - [[package]] name = "either" version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" -[[package]] -name = "encode_unicode" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" - [[package]] name = "errno" version = "0.3.1" @@ -395,7 +245,7 @@ checksum = "4bcfec3a70f97c962c307b2d2c56e358cf1d00b558d74262b5f929ee8cc7e73a" dependencies = [ "errno-dragonfly", "libc", - "windows-sys 0.48.0", + "windows-sys", ] [[package]] @@ -408,54 +258,12 @@ dependencies = [ "libc", ] -[[package]] -name = "fastrand" -version = "1.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be" -dependencies = [ - "instant", -] - -[[package]] -name = "fnv" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" - -[[package]] -name = "fs_extra" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42703706b716c37f96a77aea830392ad231f44c9e9a67872fa5548707e11b11c" - -[[package]] -name = "glob" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" - [[package]] name = "half" version = "1.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7" -[[package]] -name = "hashbrown" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" - -[[package]] -name = "hermit-abi" -version = "0.1.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" -dependencies = [ - "libc", -] - [[package]] name = "hermit-abi" version = "0.2.6" @@ -471,31 +279,6 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" -[[package]] -name = "ident_case" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" - -[[package]] -name = "indexmap" -version = "1.9.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1885e79c1fc4b10f0e172c475f458b7f7b93061064d98c3293e98c5ba0c8b399" -dependencies = [ - "autocfg", - "hashbrown", -] - -[[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.10" @@ -504,7 +287,7 @@ checksum = "9c66c74d2ae7e79a5a8f7ac924adbe38ee42a859c6539ad869eb51f0b52dc220" dependencies = [ "hermit-abi 0.3.1", "libc", - "windows-sys 0.48.0", + "windows-sys", ] [[package]] @@ -516,7 +299,7 @@ dependencies = [ "hermit-abi 0.3.1", "io-lifetimes", "rustix", - "windows-sys 0.48.0", + "windows-sys", ] [[package]] @@ -543,12 +326,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "lazy_static" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" - [[package]] name = "libc" version = "0.2.144" @@ -616,22 +393,6 @@ version = "11.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575" -[[package]] -name = "os_pipe" -version = "1.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ae859aa07428ca9a929b936690f8b12dc5f11dd8c6992a18ca93919f28bc177" -dependencies = [ - "libc", - "windows-sys 0.48.0", -] - -[[package]] -name = "os_str_bytes" -version = "6.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b7820b9daea5457c9f21c69448905d723fbd21136ccf521748f23fd49e723ee" - [[package]] name = "plotters" version = "0.3.4" @@ -690,18 +451,18 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.56" +version = "1.0.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b63bdb0cd06f1f4dedf69b254734f9b45af66e4a031e42a7480257d9898b435" +checksum = "8ad3d49ab951a01fbaafe34f2ec74122942fe18a3f9814c3268f1bb72042131b" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.27" +version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f4f29d145265ec1c483c7c654450edde0bfe043d3938d6972630663356d9500" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" dependencies = [ "proc-macro2", ] @@ -728,15 +489,6 @@ dependencies = [ "num_cpus", ] -[[package]] -name = "redox_syscall" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" -dependencies = [ - "bitflags", -] - [[package]] name = "regex" version = "1.7.1" @@ -769,7 +521,7 @@ dependencies = [ "io-lifetimes", "libc", "linux-raw-sys", - "windows-sys 0.48.0", + "windows-sys", ] [[package]] @@ -795,57 +547,35 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" [[package]] name = "serde" -version = "1.0.163" +version = "1.0.201" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2113ab51b87a539ae008b5c6c02dc020ffa39afd2d83cffcb3f4eb2722cebec2" +checksum = "780f1cebed1629e4753a1a38a3c72d30b97ec044f0aef68cb26650a3c5cf363c" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.163" +version = "1.0.201" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c805777e3930c8883389c602315a24224bcc738b63905ef87cd1420353ea93e" +checksum = "c5e405930b9796f1c00bee880d03fc7e0bb4b9a11afc776885ffe84320da2865" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.61", ] [[package]] name = "serde_json" -version = "1.0.96" +version = "1.0.117" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "057d394a50403bcac12672b2b18fb387ab6d289d957dab67dd201875391e52f1" +checksum = "455182ea6142b14f93f4bc5320a2b31c1f266b66a4a5c858b013302a5d8cbfc3" dependencies = [ "itoa", "ryu", "serde", ] -[[package]] -name = "shared_child" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0d94659ad3c2137fef23ae75b03d5241d633f8acded53d672decfa0e6e0caef" -dependencies = [ - "libc", - "winapi", -] - -[[package]] -name = "shell-words" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24188a676b6ae68c3b2cb3a01be17fbf7240ce009799bb56d5b1409051e78fde" - -[[package]] -name = "strsim" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" - [[package]] name = "syn" version = "1.0.107" @@ -859,49 +589,21 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.15" +version = "2.0.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a34fcf3e8b60f57e6a14301a2e916d323af98b0ea63c599441eec8558660c822" +checksum = "c993ed8ccba56ae856363b1845da7266a7cb78e1d146c8a32d54b45a8b831fc9" dependencies = [ "proc-macro2", "quote", "unicode-ident", ] -[[package]] -name = "tempfile" -version = "3.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9fbec84f381d5795b08656e4912bec604d162bff9291d6189a78f4c8ab87998" -dependencies = [ - "cfg-if", - "fastrand", - "redox_syscall", - "rustix", - "windows-sys 0.45.0", -] - -[[package]] -name = "termcolor" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6" -dependencies = [ - "winapi-util", -] - [[package]] name = "termtree" version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3369f5ac52d5eb6ab48c6b4ffdc8efbcad6b89c765749064ba298f2c68a16a76" -[[package]] -name = "textwrap" -version = "0.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "222a222a5bfe1bba4a77b45ec488a741b3cb8872e5e499451fd7d0129c9c7c3d" - [[package]] name = "tinytemplate" version = "1.2.1" @@ -918,12 +620,6 @@ version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc" -[[package]] -name = "unicode-width" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" - [[package]] name = "wait-timeout" version = "0.2.0" @@ -1039,52 +735,13 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" -[[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.2", - "windows_aarch64_msvc 0.42.2", - "windows_i686_gnu 0.42.2", - "windows_i686_msvc 0.42.2", - "windows_x86_64_gnu 0.42.2", - "windows_x86_64_gnullvm 0.42.2", - "windows_x86_64_msvc 0.42.2", -] - -[[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.2", -] - [[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", -] - -[[package]] -name = "windows-targets" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" -dependencies = [ - "windows_aarch64_gnullvm 0.42.2", - "windows_aarch64_msvc 0.42.2", - "windows_i686_gnu 0.42.2", - "windows_i686_msvc 0.42.2", - "windows_x86_64_gnu 0.42.2", - "windows_x86_64_gnullvm 0.42.2", - "windows_x86_64_msvc 0.42.2", + "windows-targets", ] [[package]] @@ -1093,124 +750,53 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5" 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", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", ] -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" - [[package]] name = "windows_aarch64_gnullvm" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" -[[package]] -name = "windows_aarch64_msvc" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" - [[package]] name = "windows_aarch64_msvc" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" -[[package]] -name = "windows_i686_gnu" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" - [[package]] name = "windows_i686_gnu" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" -[[package]] -name = "windows_i686_msvc" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" - [[package]] name = "windows_i686_msvc" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" -[[package]] -name = "windows_x86_64_gnu" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" - [[package]] name = "windows_x86_64_gnu" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" - [[package]] name = "windows_x86_64_gnullvm" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" -[[package]] -name = "windows_x86_64_msvc" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" - [[package]] name = "windows_x86_64_msvc" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" - -[[package]] -name = "xtask" -version = "0.1.0" -dependencies = [ - "anyhow", - "xtaskops", -] - -[[package]] -name = "xtaskops" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "464ca5c2bac1d1fcdbef9da6c09c6a14f2c7ac6c8845f574ab12065a2b72bb8b" -dependencies = [ - "anyhow", - "clap 3.2.23", - "derive_builder", - "dialoguer", - "duct", - "fs_extra", - "glob", -] - -[[package]] -name = "zeroize" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a0956f1ba7c7909bfb66c2e9e4124ab6f6482560f6628b5aaeba39207c9aad9" diff --git a/Cargo.toml b/Cargo.toml index eb518f2..a638cd8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,6 @@ [package] -authors = ["Sebastien Rousseau "] +# Metadata about the package. +authors = ["The Common (CMN) library contributors "] build = "build.rs" categories = [ "config", @@ -16,15 +17,8 @@ exclude = [ "/.github/*", "/.gitignore", "/.vscode/*" - ] -homepage = "https://minifunctions.com/" -keywords = ["cmn", "common", "config", "configurations", "constants"] -license = "MIT OR Apache-2.0" -name = "cmn" -readme = "README.md" -repository = "https://github.com/sebastienrousseau/cmn/" -rust-version = "1.69.0" -version = "0.0.3" +] +homepage = "https://cmnlib.com/" include = [ "/CONTRIBUTING.md", "/LICENSE-APACHE", @@ -36,11 +30,14 @@ include = [ "/README.md", "/src/**", "/tests/**", - "/xtask/**", ] - -[workspace] -members = ["xtask"] +keywords = ["cmn", "common", "config", "configurations", "constants"] +license = "MIT OR Apache-2.0" +name = "cmn" +readme = "README.md" +repository = "https://github.com/sebastienrousseau/cmn/" +rust-version = "1.60" +version = "0.0.4" [[bench]] name = "benchmark" @@ -55,11 +52,13 @@ name = "cmn" path = "examples/cmn.rs" [dependencies] -serde = { version = "1.0.163", features = ["derive"] } -serde_json = "1.0.96" +# Dependencies for the library +serde = { version = "1.0.201", features = ["derive"] } +serde_json = "1.0.117" [dev-dependencies] -assert_cmd = "2.0.11" +# Dependencies for testing +assert_cmd = "2.0.14" criterion = "0.5.1" [lib] @@ -68,10 +67,66 @@ name = "cmn" path = "src/lib.rs" [features] +# No default features default = [] [package.metadata.docs.rs] -all-features = true +targets = ["x86_64-unknown-linux-gnu"] +rustdoc-args = ["--generate-link-to-definition"] + +# Linting config +[lints.rust] + +## Warn +# box_pointers = "warn" +# missing_copy_implementations = "warn" +# missing_docs = "warn" +# unstable_features = "warn" +# unused_crate_dependencies = "warn" +# unused_extern_crates = "warn" +# unused_results = "warn" + +## Allow +bare_trait_objects = "allow" +elided_lifetimes_in_paths = "allow" +non_camel_case_types = "allow" +non_upper_case_globals = "allow" +trivial_bounds = "allow" +unsafe_code = "allow" + +## Forbid +missing_debug_implementations = "forbid" +non_ascii_idents = "forbid" +unreachable_pub = "forbid" + +## Deny +dead_code = "deny" +deprecated_in_future = "deny" +ellipsis_inclusive_range_patterns = "deny" +explicit_outlives_requirements = "deny" +future_incompatible = { level = "deny", priority = -1 } +keyword_idents = "deny" +macro_use_extern_crate = "deny" +meta_variable_misuse = "deny" +missing_fragment_specifier = "deny" +noop_method_call = "deny" +pointer_structural_match = "deny" +rust_2018_idioms = { level = "deny", priority = -1 } +rust_2021_compatibility = { level = "deny", priority = -1 } +single_use_lifetimes = "deny" +trivial_casts = "deny" +trivial_numeric_casts = "deny" +unused = { level = "deny", priority = -1 } +unused_features = "deny" +unused_import_braces = "deny" +unused_labels = "deny" +unused_lifetimes = "deny" +unused_macro_rules = "deny" +unused_qualifications = "deny" +variant_size_differences = "deny" + +[package.metadata.clippy] +warn-lints = ["clippy::all", "clippy::pedantic", "clippy::cargo", "clippy::nursery"] [profile.dev] codegen-units = 256 @@ -86,16 +141,16 @@ rpath = false strip = false [profile.release] -codegen-units = 1 # Compile crates one after another so the compiler can optimize better -debug = false # Disable debug information -debug-assertions = false # Disable debug assertions -incremental = false # Disable incremental compilation -lto = true # Enables link to optimizations -opt-level = "s" # Optimize for binary size -overflow-checks = false # Disable overflow checks -panic = "abort" # Strip expensive panic clean-up logic -rpath = false # Disable rpath -strip = "symbols" # Automatically strip symbols from the binary. +codegen-units = 1 +debug = false +debug-assertions = false +incremental = false +lto = true +opt-level = "s" +overflow-checks = false +panic = "abort" +rpath = false +strip = "symbols" [profile.test] codegen-units = 256 diff --git a/README.md b/README.md index 1d22fe4..f3ce355 100644 --- a/README.md +++ b/README.md @@ -141,7 +141,7 @@ To use the `Common (CMN)` library in your project, add the following to your `Ca ```toml [dependencies] -cmn = "0.0.3" +cmn = "0.0.4" ``` Add the following to your `main.rs` file: @@ -186,7 +186,7 @@ A big thank you to all the awesome contributors of the [Common (CMN) Library][6] A special thank you goes to the [Rust Reddit][13] community for providing a lot of useful suggestions on how to improve this project. -[0]: https://minifunctions.com/ "MiniFunctions" +[0]: https://cmnlib.com/ "MiniFunctions" [1]: https://cmnlib.one "Common (CMN) Library Website" [2]: https://opensource.org/license/apache-2-0/ "Apache License, Version 2.0" [3]: https://opensource.org/licenses/MIT "MIT license" @@ -208,6 +208,6 @@ A special thank you goes to the [Rust Reddit][13] community for providing a lot [crates-badge]: https://img.shields.io/crates/v/cmn.svg?style=for-the-badge 'Crates.io badge' [divider]: https://kura.pro/common/images/elements/divider.svg "divider" [docs-badge]: https://img.shields.io/docsrs/cmn.svg?style=for-the-badge 'Docs.rs badge' -[libs-badge]: https://img.shields.io/badge/lib.rs-v0.0.3-orange.svg?style=for-the-badge 'Lib.rs badge' +[libs-badge]: https://img.shields.io/badge/lib.rs-v0.0.4-orange.svg?style=for-the-badge 'Lib.rs badge' [license-badge]: https://img.shields.io/crates/l/cmn.svg?style=for-the-badge 'License badge' [made-with-rust-badge]: https://img.shields.io/badge/rust-f04041?style=for-the-badge&labelColor=c0282d&logo=rust 'Made With Rust badge' diff --git a/TEMPLATE.md b/TEMPLATE.md index 2d690a2..92d4500 100644 --- a/TEMPLATE.md +++ b/TEMPLATE.md @@ -49,7 +49,7 @@ represents the different constant values. The values can be an `f64 float`, a `String`, a `u32`, a `usize`, or a `&'static [char]` array of characters. -[0]: https://minifunctions.com/ "MiniFunctions" +[0]: https://cmnlib.com/ "MiniFunctions" [1]: https://cmnlib.one "Common (CMN) Library Website" [2]: https://opensource.org/license/apache-2-0/ "Apache License, Version 2.0" [4]: https://github.com/sebastienrousseau/cmn/issues "Issues" @@ -65,7 +65,7 @@ array of characters. [crates-badge]: https://img.shields.io/crates/v/cmn.svg?style=for-the-badge 'Crates.io badge' [divider]: https://kura.pro/common/images/elements/divider.svg "divider" [docs-badge]: https://img.shields.io/docsrs/cmn.svg?style=for-the-badge 'Docs.rs badge' -[libs-badge]: https://img.shields.io/badge/lib.rs-v0.0.3-orange.svg?style=for-the-badge 'Lib.rs badge' +[libs-badge]: https://img.shields.io/badge/lib.rs-v0.0.4-orange.svg?style=for-the-badge 'Lib.rs badge' [license-badge]: https://img.shields.io/crates/l/cmn.svg?style=for-the-badge 'License badge' [made-with-rust-badge]: https://img.shields.io/badge/rust-f04041?style=for-the-badge&labelColor=c0282d&logo=rust 'Made With Rust badge' diff --git a/benches/criterion.rs b/benches/criterion.rs index 52eac87..9894918 100644 --- a/benches/criterion.rs +++ b/benches/criterion.rs @@ -2,6 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 OR MIT //! Benchmarks for the Common (CMN) library. +#![allow(missing_docs)] use criterion::{ black_box, criterion_group, criterion_main, Criterion, }; @@ -28,7 +29,7 @@ fn bench_words(c: &mut Criterion) { }); c.bench_function("Words::default", |b| { b.iter(|| { - let words = black_box(Words::default()); + let words = black_box(Words {}); let _ = black_box(words.words_list()); }) }); diff --git a/src/lib.rs b/src/lib.rs index 94580bf..e26811c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -7,13 +7,13 @@ //! //! *Part of the [Mini Functions][0] family of libraries.* //! -//! [![Common (CMN)](https://kura.pro/cmn/images/titles/title-cmn.svg)](https://minifunctions.com/cmn) +//! [![Common (CMN)](https://kura.pro/cmn/images/titles/title-cmn.svg)](https://cmnlib.com/cmn) //! //!
//! //! [![Crates.io](https://img.shields.io/crates/v/cmn.svg?style=for-the-badge&color=success&labelColor=27A006)](https://crates.io/crates/cmn) //! [![GitHub](https://img.shields.io/badge/github-555555?style=for-the-badge&labelColor=000000&logo=github)](https://github.com/sebastienrousseau/cmn) -//! [![Lib.rs](https://img.shields.io/badge/lib.rs-v0.0.3-success.svg?style=for-the-badge&color=8A48FF&labelColor=6F36E4)](https://lib.rs/crates/cmn) +//! [![Lib.rs](https://img.shields.io/badge/lib.rs-v0.0.4-success.svg?style=for-the-badge&color=8A48FF&labelColor=6F36E4)](https://lib.rs/crates/cmn) //! [![License](https://img.shields.io/crates/l/cmn.svg?style=for-the-badge&color=007EC6&labelColor=03589B)](http://opensource.org/licenses/MIT) //! [![Rust](https://img.shields.io/badge/rust-f04041?style=for-the-badge&labelColor=c0282d&logo=rust)](https://www.rust-lang.org) //! @@ -99,14 +99,9 @@ //! defined in the Apache-2.0 license, shall be dual licensed as above, //! without any additional terms or conditions. //! -//! [0]: https://minifunctions.com/ "MiniFunctions" +//! [0]: https://cmnlib.com/ "MiniFunctions" //! #![cfg_attr(feature = "bench", feature(test))] -#![deny(dead_code)] -#![deny(missing_debug_implementations)] -#![deny(missing_docs)] -#![forbid(unsafe_code)] -#![warn(unreachable_pub)] #![doc( html_favicon_url = "https://kura.pro/cmn/images/favicon.ico", html_logo_url = "https://kura.pro/cmn/images/logos/cmn.svg", @@ -117,9 +112,7 @@ /// The `serde` crate provides the `Serialize` and `Deserialize` traits /// that are used to serialize and deserialize the data. -extern crate serde; use serde::{Deserialize, Serialize}; -use serde_json; /// The `macros` module contains functions for generating macros. pub mod macros; diff --git a/tests/test_constants.rs b/tests/test_constants.rs index 46c8a56..49bba61 100644 --- a/tests/test_constants.rs +++ b/tests/test_constants.rs @@ -3,7 +3,6 @@ #[cfg(test)] mod tests { - extern crate cmn; use cmn::constants::Constants; #[test] diff --git a/tests/test_lib.rs b/tests/test_lib.rs index de8de7d..c1dc642 100644 --- a/tests/test_lib.rs +++ b/tests/test_lib.rs @@ -3,7 +3,6 @@ #[cfg(test)] mod tests { - pub use cmn::Words; use cmn::*; #[test] diff --git a/tests/test_macros.rs b/tests/test_macros.rs index 4fc0dde..3fd1165 100644 --- a/tests/test_macros.rs +++ b/tests/test_macros.rs @@ -2,7 +2,6 @@ mod tests { // Importing cmn crate and all of its macros - extern crate cmn; use cmn::{ cmn_assert, cmn_contains, cmn_in_range, cmn_join, cmn_max, cmn_min, cmn_print, cmn_print_vec, cmn_split, cmn_vec, @@ -77,8 +76,8 @@ mod tests { #[test] fn test_cmn_in_range() { // Test that cmn_in_range! macro correctly checks if a number is within a range - assert!(cmn_in_range!(10, 0, 100)); - assert!(!cmn_in_range!(-10, 0, 100)); + cmn_assert!(cmn_in_range!(10, 0, 100)); + cmn_assert!(!cmn_in_range!(-10, 0, 100)); } #[test] diff --git a/tests/test_words.rs b/tests/test_words.rs index 7d47203..207d4d0 100644 --- a/tests/test_words.rs +++ b/tests/test_words.rs @@ -3,7 +3,7 @@ #[cfg(test)] mod tests { - pub use cmn::Words; + use cmn::Words; #[test] fn test_words_list() { @@ -16,7 +16,7 @@ mod tests { #[test] fn test_default_words() { - let words = Words::default(); + let words = Words {}; let words_list = words.words_list(); assert_eq!(words_list[0], "aboard"); assert_eq!(words_list[1], "abode"); From e72b3daa217b35d6eb255772d669855b2dabcd01 Mon Sep 17 00:00:00 2001 From: Sebastien Rousseau Date: Thu, 9 May 2024 22:42:20 +0100 Subject: [PATCH 2/7] feat(cmn): :sparkles: new constants have been added to the list of constants MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The constants include ApΓ©ry's constant, Catalan's constant, Coulomb's constant, Faraday constant, gas constant, Glaisher-Kinkelin constant, gravitational constant, Khinchin's constant, Planck's reduced constant, speed of light, vacuum permeability, and vacuum permittivity. --- src/constants.rs | 209 +++++++++++++++++++++++++++++++++------- tests/test_constants.rs | 14 ++- tests/test_lib.rs | 16 +-- tests/test_macros.rs | 65 ++++++++++--- 4 files changed, 249 insertions(+), 55 deletions(-) diff --git a/src/constants.rs b/src/constants.rs index 9ff26c3..1044b92 100644 --- a/src/constants.rs +++ b/src/constants.rs @@ -1,6 +1,9 @@ // Copyright Β© 2023 Common (CMN) library. All rights reserved. // SPDX-License-Identifier: Apache-2.0 OR MIT +// Copyright Β© 2023 Common (CMN) library. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 OR MIT + use serde::{Deserialize, Serialize}; /// Contains several commonly used mathematical and cryptographic constants. @@ -32,6 +35,55 @@ pub struct Constants { } impl Constants { + /// Returns the value of the constant. + /// + /// # Example + /// + /// ``` + /// use cmn::constants::Constants; + /// use cmn::constants::ConstantValue; + /// + /// let constants = Constants::new(); + /// let constant = constants.constant("EULER").unwrap(); + /// let value = constants.get_value(constant.name); + /// + /// if let Some(ConstantValue::Float(float_value)) = value { + /// assert!((float_value - 2.71828).abs() < 1e-5); + /// } + /// else { + /// panic!("Expected a float value"); + /// } + /// + /// ``` + pub fn get_value(&self, name: &str) -> Option { + if let Some(constant) = self.constant(name) { + if let Ok(float_value) = constant.value.parse::() { + Some(ConstantValue::Float(float_value)) + } else if let Ok(u32_value) = constant.value.parse::() + { + Some(ConstantValue::U32(u32_value)) + } else if let Ok(usize_value) = + constant.value.parse::() + { + Some(ConstantValue::Usize(usize_value)) + } else if let Some(char_array) = Self::get_char_array(name) + { + Some(ConstantValue::CharArray(char_array)) + } else { + Some(ConstantValue::String(constant.value.clone())) + } + } else { + None + } + } + + fn get_char_array(name: &str) -> Option<&'static [char]> { + match name { + "SPECIAL_CHARS" => Some(SPECIAL_CHARS), + _ => None, + } + } + /// Returns a vector of tuples with the constant name and its value. /// /// # Arguments @@ -82,12 +134,16 @@ impl Constants { /// use cmn::constants::Constants; /// /// let constants = Constants::new(); - /// assert_eq!(constants.constants().len(), 16); + /// assert_eq!(constants.constants().len(), 28); /// /// ``` /// pub fn new() -> Self { let constants = vec![ + Constant { + name: "APERY", + value: APERY.to_string(), + }, Constant { name: "AVOGADRO", value: AVOGADRO.to_string(), @@ -96,14 +152,38 @@ impl Constants { name: "BOLTZMANN", value: BOLTZMANN.to_string(), }, + Constant { + name: "CATALAN", + value: CATALAN.to_string(), + }, + Constant { + name: "COULOMB", + value: COULOMB.to_string(), + }, Constant { name: "EULER", value: EULER.to_string(), }, + Constant { + name: "FARADAY", + value: FARADAY.to_string(), + }, Constant { name: "GAMMA", value: GAMMA.to_string(), }, + Constant { + name: "GAS_CONSTANT", + value: GAS_CONSTANT.to_string(), + }, + Constant { + name: "GLAISHER_KINKELIN", + value: GLAISHER_KINKELIN.to_string(), + }, + Constant { + name: "GRAVITATIONAL_CONSTANT", + value: GRAVITATIONAL_CONSTANT.to_string(), + }, Constant { name: "HASH_ALGORITHM", value: HASH_ALGORITHM.to_string(), @@ -116,6 +196,10 @@ impl Constants { name: "HASH_LENGTH", value: HASH_LENGTH.to_string(), }, + Constant { + name: "KHINCHIN", + value: KHINCHIN.to_string(), + }, Constant { name: "PHI", value: PHI.to_string(), @@ -128,10 +212,18 @@ impl Constants { name: "PLANCK", value: PLANCK.to_string(), }, + Constant { + name: "PLANCK_REDUCED", + value: PLANCK_REDUCED.to_string(), + }, Constant { name: "SILVER_RATIO", value: SILVER_RATIO.to_string(), }, + Constant { + name: "SPEED_OF_LIGHT", + value: SPEED_OF_LIGHT.to_string(), + }, Constant { name: "SPECIAL_CHARS", value: SPECIAL_CHARS.iter().collect::(), @@ -152,6 +244,14 @@ impl Constants { name: "TAU", value: TAU.to_string(), }, + Constant { + name: "VACUUM_PERMEABILITY", + value: VACUUM_PERMEABILITY.to_string(), + }, + Constant { + name: "VACUUM_PERMITTIVITY", + value: VACUUM_PERMITTIVITY.to_string(), + }, ]; Self { constants } @@ -188,23 +288,50 @@ pub enum ConstantValue { CharArray(&'static [char]), } -/// Avogadro's constant -/// Approximately 6.02214076 x 10^23 -pub const AVOGADRO: f64 = 602214076000000000000000.0; +/// ApΓ©ry's constant, which is the sum of the reciprocals of the positive cubes. +/// ΞΆ(3) β‰ˆ 1.2020569032 +pub const APERY: f64 = 1.2020569031595942; + +/// Avogadro's constant, which is the number of constituent particles contained in one mole of a substance. +/// N_A β‰ˆ 6.02214076 x 10^23 mol^-1 +pub const AVOGADRO: f64 = 6.02214076e23; -/// Boltzmann's constant -/// Approximately 1.380648 x 10^-23 +/// Boltzmann's constant, which relates the average kinetic energy of particles in a gas with the temperature of the gas. +/// k_B β‰ˆ 1.380648 x 10^-23 J K^-1 pub const BOLTZMANN: f64 = 1.380648e-23; -/// The base of the natural logarithm, Euler's number (e). +/// Catalan's constant, which is the sum of the alternating harmonic series. +/// C β‰ˆ 0.9159655942 +pub const CATALAN: f64 = 0.9159655941772190; + +/// Coulomb's constant, which is the proportionality constant in Coulomb's law. +/// k_e β‰ˆ 8.9875517923 x 10^9 N m^2 C^-2 +pub const COULOMB: f64 = 8.9875517923e9; + +/// The base of the natural logarithm, Euler's number. /// e β‰ˆ 2.7182818284590452353602874713527 pub const EULER: f64 = std::f64::consts::E; -/// The mathematical constant `Ξ³` or the Euler–Mascheroni constant. It -/// is the limit of the difference between the harmonic series and the -/// natural logarithm of the natural numbers. +/// Faraday constant, which represents the amount of electric charge carried by one mole of electrons. +/// F β‰ˆ 96485.33212 C mol^-1 +pub const FARADAY: f64 = 96485.33212; + +/// The Euler-Mascheroni constant, which is the limiting difference between the harmonic series and the natural logarithm. +/// Ξ³ β‰ˆ 0.5772156649015329 pub const GAMMA: f64 = 0.5772156649015329; +/// The gas constant, which relates the energy scale to the temperature scale in the ideal gas law. +/// R β‰ˆ 8.314462618 J mol^-1 K^-1 +pub const GAS_CONSTANT: f64 = 8.314462618; + +/// Glaisher-Kinkelin constant, which arises in the asymptotic expansion of the Barnes G-function. +/// A β‰ˆ 1.2824271291 +pub const GLAISHER_KINKELIN: f64 = 1.2824271291006226; + +/// The gravitational constant, which is the proportionality constant in Newton's law of universal gravitation. +/// G β‰ˆ 6.67430 x 10^-11 m^3 kg^-1 s^-2 +pub const GRAVITATIONAL_CONSTANT: f64 = 6.67430e-11; + /// The hash algorithm used. The default is Blake3. pub const HASH_ALGORITHM: &str = "Blake3"; @@ -217,22 +344,34 @@ pub const HASH_COST: u32 = 8; /// - The minimum is 16. pub const HASH_LENGTH: usize = 32; -/// The mathematical constant `Ο†` or the golden ratio. It is the -/// limit of the ratio of consecutive Fibonacci numbers. -/// Ξ¦ = (1+√5)/2 = 2.cos(Ο€/5). Diagonal of a unit-side pentagon. +/// Khinchin's constant, which appears in the theory of continued fractions. +/// K β‰ˆ 2.6854520010 +pub const KHINCHIN: f64 = 2.6854520010653064; + +/// The golden ratio, which is the limit of the ratio of consecutive Fibonacci numbers. +/// Ο† = (1 + √5) / 2 β‰ˆ 1.6180339887498948482045868343656 pub const PHI: f64 = (1.0 + SQRT5) / 2.0; -/// The mathematical constant `Ο€` or the ratio of a circle's -/// circumference to its diameter. +/// The ratio of a circle's circumference to its diameter. +/// Ο€ β‰ˆ 3.14159265358979323846264338327950288 pub const PI: f64 = std::f64::consts::PI; -/// The Planck constant, `h`. +/// Planck's constant, which relates the energy of a photon to its frequency. +/// h β‰ˆ 6.62607015 x 10^-34 J s pub const PLANCK: f64 = 6.62607015e-34; -/// The mathematical constant `Ξ΄s' or the silver ratio (or silver mean). -/// Ξ΄s = 1+√2. One of the silver means (n+sqrt(n2+1))/2 for n>0. +/// Planck's reduced constant, which is Planck's constant divided by 2Ο€. +/// Δ§ = h / (2Ο€) β‰ˆ 1.054571817 x 10^-34 J s +pub const PLANCK_REDUCED: f64 = PLANCK / (2.0 * PI); + +/// The silver ratio, which is one of the silver means. +/// Ξ΄_s = 1 + √2 β‰ˆ 2.4142135623730950488016887242097 pub const SILVER_RATIO: f64 = 1.0 + SQRT2; +/// The speed of light in vacuum. +/// c β‰ˆ 299792458 m s^-1 +pub const SPEED_OF_LIGHT: f64 = 299792458.0; + /// A set of special characters. pub const SPECIAL_CHARS: &[char] = &[ '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '+', '=', @@ -240,24 +379,26 @@ pub const SPECIAL_CHARS: &[char] = &[ '/', '~', '`', ]; -/// The mathematical constant `√2` or the Pythagora's constant or the -/// square root of 2. It is the diagonal of a square with unit side -/// length. -/// 2 = 1 + √2 +/// The square root of 2. +/// √2 β‰ˆ 1.4142135623730950488016887242097 pub const SQRT2: f64 = std::f64::consts::SQRT_2; -/// The mathematical constant `√3` or the principal square root of 3. -/// It is the length of the side of an equilateral triangle with unit -/// side length. -/// 3 = 1 + √3 -pub const SQRT3: f64 = 1.732_050_807_568_877_2; +/// The square root of 3. +/// √3 β‰ˆ 1.7320508075688772935274463415059 +pub const SQRT3: f64 = 1.7320508075688772; -/// The mathematical constant `√5` or the principal square root of 5. -/// It is the length of the diagonal of a regular pentagon with unit -/// side length. -/// 5 = 2 + 2√5 -pub const SQRT5: f64 = 2.236_067_977_499_79; +/// The square root of 5. +/// √5 β‰ˆ 2.2360679774997896964091736687313 +pub const SQRT5: f64 = 2.2360679774997896; -/// The mathematical constant `Ο„` or the ratio of a circle's -/// circumference to its radius. +/// The circle constant, which is the ratio of a circle's circumference to its radius. +/// Ο„ = 2Ο€ β‰ˆ 6.28318530717958647692528676655900577 pub const TAU: f64 = std::f64::consts::TAU; + +/// The vacuum permeability, which relates magnetic induction to magnetic field strength. +/// ΞΌ_0 β‰ˆ 1.25663706212 x 10^-6 N A^-2 +pub const VACUUM_PERMEABILITY: f64 = 1.25663706212e-6; + +/// The vacuum permittivity, which relates electric displacement to electric field strength. +/// Ξ΅_0 β‰ˆ 8.8541878128 x 10^-12 F m^-1 +pub const VACUUM_PERMITTIVITY: f64 = 8.8541878128e-12; diff --git a/tests/test_constants.rs b/tests/test_constants.rs index 49bba61..94664d0 100644 --- a/tests/test_constants.rs +++ b/tests/test_constants.rs @@ -20,26 +20,38 @@ mod tests { fn test_constants() { let new_constant = Constants::new(); let constants = new_constant.constants(); - assert_eq!(constants.len(), 16); + assert_eq!(constants.len(), 28); let names = constants.iter().map(|c| c.name).collect::>(); + assert!(names.contains(&"APERY")); assert!(names.contains(&"AVOGADRO")); assert!(names.contains(&"BOLTZMANN")); + assert!(names.contains(&"CATALAN")); + assert!(names.contains(&"COULOMB")); assert!(names.contains(&"EULER")); + assert!(names.contains(&"FARADAY")); assert!(names.contains(&"GAMMA")); + assert!(names.contains(&"GAS_CONSTANT")); + assert!(names.contains(&"GLAISHER_KINKELIN")); + assert!(names.contains(&"GRAVITATIONAL_CONSTANT")); assert!(names.contains(&"HASH_ALGORITHM")); assert!(names.contains(&"HASH_COST")); assert!(names.contains(&"HASH_LENGTH")); + assert!(names.contains(&"KHINCHIN")); assert!(names.contains(&"PHI")); assert!(names.contains(&"PI")); assert!(names.contains(&"PLANCK")); + assert!(names.contains(&"PLANCK_REDUCED")); assert!(names.contains(&"SILVER_RATIO")); + assert!(names.contains(&"SPEED_OF_LIGHT")); assert!(names.contains(&"SPECIAL_CHARS")); assert!(names.contains(&"SQRT2")); assert!(names.contains(&"SQRT3")); assert!(names.contains(&"SQRT5")); assert!(names.contains(&"TAU")); + assert!(names.contains(&"VACUUM_PERMEABILITY")); + assert!(names.contains(&"VACUUM_PERMITTIVITY")); } #[test] fn test_new() { diff --git a/tests/test_lib.rs b/tests/test_lib.rs index c1dc642..82c89ee 100644 --- a/tests/test_lib.rs +++ b/tests/test_lib.rs @@ -10,7 +10,7 @@ mod tests { let constants = Constants::new(); assert!(constants.is_valid()); assert!(constants.constants.len() >= 9); - assert!(constants.constants.len() <= 16); + assert!(constants.constants.len() <= 28); } #[test] @@ -25,7 +25,7 @@ mod tests { let constants = Constants::new(); let new_constants = constants.constants(); - assert_eq!(new_constants.len(), 16); + assert_eq!(new_constants.len(), 28); assert_eq!(new_constants, constants.constants()); } @@ -41,7 +41,7 @@ mod tests { let common = Common::default(); let constants = common.constants(); - assert_eq!(constants.constants().len(), 16); + assert_eq!(constants.constants().len(), 28); assert_eq!( constants.constants(), Constants::default().constants() @@ -53,7 +53,7 @@ mod tests { let constants = Constants::new(); let new_constants = constants.constants(); - assert_eq!(new_constants.len(), 16); + assert_eq!(new_constants.len(), 28); assert_eq!(new_constants, Constants::default().constants()); } @@ -62,8 +62,8 @@ mod tests { let constants = Constants::new(); let new_constants = constants.constants().to_vec(); - assert_eq!(new_constants.len(), 16); - assert_eq!(constants.constants().len(), 16); + assert_eq!(new_constants.len(), 28); + assert_eq!(constants.constants().len(), 28); assert_eq!(new_constants, constants.constants().to_vec()); } @@ -72,7 +72,7 @@ mod tests { let constants = Constants::new(); let new_constants = constants.constants(); - assert_eq!(new_constants.len(), 16); + assert_eq!(new_constants.len(), 28); assert_eq!(new_constants, Constants::default().constants()); } @@ -82,7 +82,7 @@ mod tests { let binding = Constants::default(); let default_constants = binding.constants(); - assert_eq!(default_constants.len(), 16); + assert_eq!(default_constants.len(), 28); assert_eq!(default_constants, constants.constants()); } diff --git a/tests/test_macros.rs b/tests/test_macros.rs index 3fd1165..7b27211 100644 --- a/tests/test_macros.rs +++ b/tests/test_macros.rs @@ -3,9 +3,8 @@ mod tests { // Importing cmn crate and all of its macros use cmn::{ - cmn_assert, cmn_contains, cmn_in_range, cmn_join, cmn_max, - cmn_min, cmn_print, cmn_print_vec, cmn_split, cmn_vec, - constants::*, + cmn_assert, cmn_contains, cmn_join, cmn_max, cmn_min, + cmn_print, cmn_print_vec, cmn_split, cmn_vec, constants::*, }; #[test] @@ -73,16 +72,13 @@ mod tests { assert!(!cmn_contains!("Hello", "x")); } - #[test] - fn test_cmn_in_range() { - // Test that cmn_in_range! macro correctly checks if a number is within a range - cmn_assert!(cmn_in_range!(10, 0, 100)); - cmn_assert!(!cmn_in_range!(-10, 0, 100)); - } - #[test] fn test_cmn_constants() { // Test that each constant defined by the cmn_constants! macro has the expected value or is not empty + assert_eq!( + APERY, 1.2020569031595942, + "APERY should have a specific value" + ); assert_eq!( AVOGADRO, 6.02214076e23, "AVOGADRO should have a specific value" @@ -92,13 +88,38 @@ mod tests { "BOLTZMANN should have a specific value" ); assert_eq!( - EULER, std::f64::consts::E, + CATALAN, 0.9159655941772190, + "CATALAN should have a specific value" + ); + assert_eq!( + COULOMB, 8.9875517923e9, + "COULOMB should have a specific value" + ); + assert_eq!( + EULER, + std::f64::consts::E, "EULER should have a specific value" ); + assert_eq!( + FARADAY, 96485.33212, + "FARADAY should have a specific value" + ); assert_eq!( GAMMA, 0.5772156649015329, "GAMMA should have a specific value" ); + assert_eq!( + GAS_CONSTANT, 8.314462618, + "GAS_CONSTANT should have a specific value" + ); + assert_eq!( + GLAISHER_KINKELIN, 1.2824271291006226, + "GLAISHER_KINKELIN should have a specific value" + ); + assert_eq!( + GRAVITATIONAL_CONSTANT, 6.67430e-11, + "GRAVITATIONAL_CONSTANT should have a specific value" + ); assert_eq!( HASH_ALGORITHM, "Blake3", "HASH_ALGORITHM should have a specific value" @@ -111,6 +132,10 @@ mod tests { HASH_LENGTH, 32, "HASH_LENGTH should have a specific value" ); + assert_eq!( + KHINCHIN, 2.6854520010653064, + "KHINCHIN should have a specific value" + ); assert_eq!( PHI, (1.0 + SQRT5) / 2.0, @@ -125,11 +150,19 @@ mod tests { PLANCK, 6.62607015e-34, "PLANCK should have a specific value" ); + assert_eq!( + PLANCK_REDUCED, 1.0545718176461565e-34, + "PLANCK_REDUCED should have a specific value" + ); assert_eq!( SILVER_RATIO, 1.0 + SQRT2, "SILVER_RATIO should have a specific value" ); + assert_eq!( + SPEED_OF_LIGHT, 299_792_458.0, + "SPEED_OF_LIGHT should have a specific value" + ); assert_eq!( SPECIAL_CHARS, &[ @@ -149,9 +182,17 @@ mod tests { "SQRT3 should have a specific value" ); assert_eq!( - SQRT5, 2.23606797749979, + SQRT5, 2.2360679774997896, "SQRT5 should have a specific value" ); assert_eq!(TAU, 2.0 * PI, "TAU should have a specific value"); + assert_eq!( + VACUUM_PERMEABILITY, 1.25663706212e-6, + "VACUUM_PERMEABILITY should have a specific value" + ); + assert_eq!( + VACUUM_PERMITTIVITY, 8.8541878128e-12, + "VACUUM_PERMITTIVITY should have a specific value" + ); } } From f63ff26fbe768258faeae58abfd2c7cfc9a2bf3f Mon Sep 17 00:00:00 2001 From: Sebastien Rousseau Date: Thu, 9 May 2024 22:48:15 +0100 Subject: [PATCH 3/7] fix(cmn): :bug: resolve error: float has excessive precision --- src/constants.rs | 8 ++++---- tests/test_macros.rs | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/constants.rs b/src/constants.rs index 1044b92..224bbcd 100644 --- a/src/constants.rs +++ b/src/constants.rs @@ -301,8 +301,8 @@ pub const AVOGADRO: f64 = 6.02214076e23; pub const BOLTZMANN: f64 = 1.380648e-23; /// Catalan's constant, which is the sum of the alternating harmonic series. -/// C β‰ˆ 0.9159655942 -pub const CATALAN: f64 = 0.9159655941772190; +/// C β‰ˆ 0.915965594177219 +pub const CATALAN: f64 = 0.915_965_594_177_219; /// Coulomb's constant, which is the proportionality constant in Coulomb's law. /// k_e β‰ˆ 8.9875517923 x 10^9 N m^2 C^-2 @@ -388,8 +388,8 @@ pub const SQRT2: f64 = std::f64::consts::SQRT_2; pub const SQRT3: f64 = 1.7320508075688772; /// The square root of 5. -/// √5 β‰ˆ 2.2360679774997896964091736687313 -pub const SQRT5: f64 = 2.2360679774997896; +/// √5 β‰ˆ 2.23606797749979 +pub const SQRT5: f64 = 2.236_067_977_499_79; /// The circle constant, which is the ratio of a circle's circumference to its radius. /// Ο„ = 2Ο€ β‰ˆ 6.28318530717958647692528676655900577 diff --git a/tests/test_macros.rs b/tests/test_macros.rs index 7b27211..40edcdb 100644 --- a/tests/test_macros.rs +++ b/tests/test_macros.rs @@ -88,7 +88,7 @@ mod tests { "BOLTZMANN should have a specific value" ); assert_eq!( - CATALAN, 0.9159655941772190, + CATALAN, 0.915_965_594_177_219, "CATALAN should have a specific value" ); assert_eq!( @@ -182,7 +182,7 @@ mod tests { "SQRT3 should have a specific value" ); assert_eq!( - SQRT5, 2.2360679774997896, + SQRT5, 2.236_067_977_499_79, "SQRT5 should have a specific value" ); assert_eq!(TAU, 2.0 * PI, "TAU should have a specific value"); From e371f8a183bde6740663987316a5737f50609ec3 Mon Sep 17 00:00:00 2001 From: Sebastien Rousseau Date: Thu, 9 May 2024 23:25:44 +0100 Subject: [PATCH 4/7] test(cmn): :white_check_mark: added the following additional tests: `test_get_value`, `test_is_valid` --- src/constants.rs | 40 +++++++++++++++---------- tests/test_constants.rs | 65 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 89 insertions(+), 16 deletions(-) diff --git a/src/constants.rs b/src/constants.rs index 224bbcd..34e8fee 100644 --- a/src/constants.rs +++ b/src/constants.rs @@ -57,20 +57,30 @@ impl Constants { /// ``` pub fn get_value(&self, name: &str) -> Option { if let Some(constant) = self.constant(name) { - if let Ok(float_value) = constant.value.parse::() { - Some(ConstantValue::Float(float_value)) - } else if let Ok(u32_value) = constant.value.parse::() - { - Some(ConstantValue::U32(u32_value)) - } else if let Ok(usize_value) = - constant.value.parse::() - { - Some(ConstantValue::Usize(usize_value)) - } else if let Some(char_array) = Self::get_char_array(name) - { - Some(ConstantValue::CharArray(char_array)) - } else { - Some(ConstantValue::String(constant.value.clone())) + match name { + "HASH_COST" => { + constant.value.parse().map(ConstantValue::U32).ok() + } + "HASH_LENGTH" => constant + .value + .parse() + .map(ConstantValue::Usize) + .ok(), + _ => { + if let Ok(float_value) = + constant.value.parse::() + { + Some(ConstantValue::Float(float_value)) + } else if let Some(char_array) = + Self::get_char_array(name) + { + Some(ConstantValue::CharArray(char_array)) + } else { + Some(ConstantValue::String( + constant.value.clone(), + )) + } + } } } else { None @@ -190,7 +200,7 @@ impl Constants { }, Constant { name: "HASH_COST", - value: HASH_COST.to_string(), + value: HASH_COST.to_string(), // Remove this line }, Constant { name: "HASH_LENGTH", diff --git a/tests/test_constants.rs b/tests/test_constants.rs index 94664d0..e6cd632 100644 --- a/tests/test_constants.rs +++ b/tests/test_constants.rs @@ -3,7 +3,7 @@ #[cfg(test)] mod tests { - use cmn::constants::Constants; + use cmn::constants::{ConstantValue, Constants}; #[test] fn test_constant() { @@ -53,16 +53,79 @@ mod tests { assert!(names.contains(&"VACUUM_PERMEABILITY")); assert!(names.contains(&"VACUUM_PERMITTIVITY")); } + #[test] fn test_new() { let new_constant = Constants::new(); let constants = new_constant.constants(); assert!(!constants.is_empty()); } + #[test] fn test_default() { let default_constant = Constants::default(); let constants = default_constant.constants(); assert!(!constants.is_empty()); } + + #[test] + fn test_get_value() { + let constants = Constants::new(); + + // Test getting a float value + let value = constants.get_value("EULER"); + assert!(value.is_some()); + if let Some(ConstantValue::Float(float_value)) = value { + assert!((float_value - std::f64::consts::E).abs() < 1e-10); + } else { + panic!("Expected a float value"); + } + + // Test getting a string value + let value = constants.get_value("HASH_ALGORITHM"); + assert!(value.is_some()); + if let Some(ConstantValue::String(string_value)) = value { + assert_eq!(string_value, "Blake3"); + } else { + panic!("Expected a string value"); + } + + // Test getting a u32 value + let value = constants.get_value("HASH_COST"); + assert!(value.is_some()); + if let Some(ConstantValue::U32(u32_value)) = value { + assert_eq!(u32_value, 8); + } else { + panic!("Expected a u32 value"); + } + + // Test getting a usize value + let value = constants.get_value("HASH_LENGTH"); + assert!(value.is_some()); + if let Some(ConstantValue::Usize(usize_value)) = value { + assert_eq!(usize_value, 32); + } else { + panic!("Expected a usize value"); + } + + // Test getting a char array value + let value = constants.get_value("SPECIAL_CHARS"); + assert!(value.is_some()); + if let Some(ConstantValue::CharArray(char_array)) = value { + assert_eq!( + char_array, + &[ + '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', + '_', '+', '=', '[', ']', '{', '}', '|', ';', ':', + '"', '<', '>', ',', '.', '?', '/', '~', '`' + ] + ); + } else { + panic!("Expected a char array value"); + } + + // Test getting a non-existent constant value + let value = constants.get_value("NON_EXISTENT"); + assert!(value.is_none()); + } } From 9cf7544de1dee5cb2c1012c3c959032978761d32 Mon Sep 17 00:00:00 2001 From: Sebastien Rousseau Date: Sat, 11 May 2024 08:05:31 +0100 Subject: [PATCH 5/7] refactor(cmn): :art: refactoring code and removal of xtask --- Cargo.toml | 10 +-- benches/criterion.rs | 8 ++- src/constants.rs | 3 - src/lib.rs | 50 ++++++++++++--- src/words.rs | 142 +++++++++++++++++++++++++++++++------------ tests/test_lib.rs | 9 +-- tests/test_words.rs | 78 ++++++++++++++++++++---- xtask/Cargo.toml | 12 ---- xtask/src/main.rs | 13 ---- 9 files changed, 226 insertions(+), 99 deletions(-) delete mode 100644 xtask/Cargo.toml delete mode 100644 xtask/src/main.rs diff --git a/Cargo.toml b/Cargo.toml index a638cd8..e56c136 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -79,12 +79,12 @@ rustdoc-args = ["--generate-link-to-definition"] ## Warn # box_pointers = "warn" -# missing_copy_implementations = "warn" -# missing_docs = "warn" -# unstable_features = "warn" +missing_copy_implementations = "warn" +missing_docs = "warn" +unstable_features = "warn" # unused_crate_dependencies = "warn" -# unused_extern_crates = "warn" -# unused_results = "warn" +unused_extern_crates = "warn" +unused_results = "warn" ## Allow bare_trait_objects = "allow" diff --git a/benches/criterion.rs b/benches/criterion.rs index 9894918..6e54440 100644 --- a/benches/criterion.rs +++ b/benches/criterion.rs @@ -2,7 +2,9 @@ // SPDX-License-Identifier: Apache-2.0 OR MIT //! Benchmarks for the Common (CMN) library. + #![allow(missing_docs)] + use criterion::{ black_box, criterion_group, criterion_main, Criterion, }; @@ -20,6 +22,7 @@ fn bench_cmn(c: &mut Criterion) { }); }); } + fn bench_words(c: &mut Criterion) { c.bench_function("Words::new", |b| { b.iter(|| { @@ -27,13 +30,14 @@ fn bench_words(c: &mut Criterion) { let _ = black_box(words.words_list()); }) }); + c.bench_function("Words::default", |b| { b.iter(|| { - let words = black_box(Words {}); + let words = black_box(Words::default()); let _ = black_box(words.words_list()); }) }); } criterion_group!(benches, bench_cmn, bench_words); -criterion_main!(benches); +criterion_main!(benches); \ No newline at end of file diff --git a/src/constants.rs b/src/constants.rs index 34e8fee..c82fb1b 100644 --- a/src/constants.rs +++ b/src/constants.rs @@ -1,9 +1,6 @@ // Copyright Β© 2023 Common (CMN) library. All rights reserved. // SPDX-License-Identifier: Apache-2.0 OR MIT -// Copyright Β© 2023 Common (CMN) library. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 OR MIT - use serde::{Deserialize, Serialize}; /// Contains several commonly used mathematical and cryptographic constants. diff --git a/src/lib.rs b/src/lib.rs index e26811c..c48c4c1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -75,6 +75,7 @@ //! extern crate cmn; //! use cmn::Constants; //! use cmn::Words; +//! use cmn::words::WORD_LIST; //! //! // Constants //! let constants = Constants::new(); @@ -82,9 +83,11 @@ //! assert_eq!(constant.unwrap().name, "EULER"); //! //! // Words -//! let words = Words::new(); +//! let words = Words::default(); //! let words_list = words.words_list(); -//! assert_eq!(words_list[0], "aboard"); +//! // Checking the first three elements to verify correct initialization and ordering +//! assert_eq!(words_list.len(), WORD_LIST.len(), "Default words list length should match WORD_LIST length."); +//! assert_eq!(words_list[0], "aboard", "Check that words list is sorted and starts with the first word."); //! //! ``` //! ## License @@ -110,6 +113,8 @@ #![crate_name = "cmn"] #![crate_type = "lib"] +use std::collections::HashSet; + /// The `serde` crate provides the `Serialize` and `Deserialize` traits /// that are used to serialize and deserialize the data. use serde::{Deserialize, Serialize}; @@ -158,15 +163,44 @@ impl Common { } /// Returns a new instance of the `Words` structure. pub fn words(&self) -> Words { - Words::new() + let words_data = self + .fields + .get("words") + .expect("Words data not found in JSON") + .as_array() + .expect("Words data is not an array") + .iter() + .map(|word_value| word_value.as_str().unwrap().to_string()) + .collect::>(); // Add type annotation here + + Words { + words: HashSet::from_iter(words_data), + } } /// Parses a string of JSON data and returns a new instance of the /// `Common` structure. - pub fn parse( - input: &str, - ) -> Result> { - let common: Common = serde_json::from_str(input)?; - Ok(common) + pub fn parse(input: &str) -> Result { + match serde_json::from_str(input) { + Ok(common) => Ok(common), + Err(e) => { + // Handle the JSON parsing error + match e.classify() { + serde_json::error::Category::Io => { + eprintln!("I/O error occurred: {}", e); + } + serde_json::error::Category::Syntax => { + eprintln!("JSON syntax error: {}", e); + } + serde_json::error::Category::Data => { + eprintln!("Invalid JSON data: {}", e); + } + serde_json::error::Category::Eof => { + eprintln!("Unexpected end of JSON input"); + } + } + Err(e) + } + } } } diff --git a/src/words.rs b/src/words.rs index ff16157..bc15202 100644 --- a/src/words.rs +++ b/src/words.rs @@ -1,33 +1,96 @@ // Copyright Β© 2023 Common (CMN) library. All rights reserved. // SPDX-License-Identifier: Apache-2.0 OR MIT -/// The `serde` crate provides the `Serialize` and `Deserialize` traits -/// that are used to serialize and deserialize the data. -extern crate serde; +//! This module provides a structured way to manage a collection of words. +//! It is primarily used in applications where word manipulation is necessary, +//! such as generating passphrases or similar textual content. + use serde::{Deserialize, Serialize}; +use std::collections::HashSet; -/// Contains several words for use in generating passphrases. +/// A structure to hold and manage a set of words. +/// +/// `Words` can be used to store words and perform operations on them, +/// such as retrieving them as a list for passphrase generation. The words are stored +/// in a `HashSet` to ensure quick lookups and to avoid duplicates, making it more +/// efficient than a list, especially with large datasets. #[derive(Clone, Serialize, Deserialize, Debug)] -pub struct Words; +pub struct Words { + /// The set of words stored in the structure. + /// + /// The `HashSet` is used to ensure that words are unique and to provide + /// efficient lookups. + pub words: HashSet, +} impl Words { - /// Creates a new instance of `Words`. + /// Constructs a new, empty `Words`. pub fn new() -> Self { - Words + Words { + words: HashSet::new(), + } } - /// Returns a list of words for use in generating passphrases. - pub fn words_list(&self) -> &'static [&'static str] { - WORD_LIST + + /// Constructs a new `Words` instance from a list of words. + pub fn words(&self) -> &Words { + self + } + + /// Returns a list of all words stored in the structure. + /// + /// This method provides access to the words as a sorted vector. It is useful for operations + /// that may require ordered data, like displaying words in a user interface. + pub fn words_list(&self) -> Vec { + let mut words_vec: Vec = self.words.iter().cloned().collect(); + words_vec.sort(); + words_vec + } + + /// Adds a word to the set. + /// + /// If the word already exists, it will not be added again due to the properties of the `HashSet`. + pub fn add_word(&mut self, word: &str) { + let _ = self.words.insert(word.to_string()); + } + + /// Checks if a word exists in the set. + pub fn contains(&self, word: &str) -> bool { + self.words.contains(word) + } + + /// Returns the number of words in the set. + pub fn count(&self) -> usize { + self.words.len() + } + + /// Clears all words from the set. + pub fn clear(&mut self) { + self.words.clear(); + } + + /// Removes a word from the set. + /// + /// Returns true if the word was present in the set, otherwise false. + pub fn remove_word(&mut self, word: &str) -> bool { + self.words.remove(word) } } impl Default for Words { + /// Populates the `Words` struct with a predefined list of words. + /// + /// This method is automatically called when creating a new instance of `Words` + /// using `Words::default()`. fn default() -> Self { - Self::new() + let mut words = Words::new(); + for word in WORD_LIST.iter() { + words.add_word(word); + } + words } } -/// The list of words. +/// The predefined list of words used to initialize the `Words` struct. pub const WORD_LIST: &[&str] = &[ "aboard", "abode", "abort", "abound", "about", "above", "abroad", "abrupt", "absent", "absorb", "absurd", "abuse", "accent", @@ -35,9 +98,8 @@ pub const WORD_LIST: &[&str] = &[ "acid", "acidic", "acorn", "acre", "across", "act", "action", "active", "actor", "actual", "acute", "adapt", "add", "added", "addict", "adept", "adhere", "adjust", "admire", "admit", "adam", - "afghan", "alaska", "alice", "allah", "amazon", "andrew", "anglo", - "angola", "antony", "adobe", "adopt", "adrift", "adult", "adverb", "advert", "aerial", "afar", "affair", "affect", "afford", "afield", + "afghan", "alaska", "alice", "allah", "amazon", "andrew", "anglo", "afloat", "afraid", "afresh", "after", "again", "age", "agency", "agenda", "agent", "aghast", "agile", "ago", "agony", "agree", "agreed", "ahead", "aid", "aide", "aim", "air", "airman", "airy", @@ -48,12 +110,12 @@ pub const WORD_LIST: &[&str] = &[ "altar", "alter", "always", "amaze", "amber", "ambush", "amen", "amend", "amid", "amidst", "amiss", "among", "amount", "ample", "amuse", "anchor", "and", "anew", "angel", "anger", "angle", + "angola", "antony", "adobe", "adopt", "adrift", "adult", "adverb", "angry", "animal", "ankle", "annoy", "annual", "answer", "anthem", "anti", "any", "anyhow", "anyway", "apart", "apathy", "apex", "apiece", "appeal", "appear", "apple", "apply", "apron", "arcade", - "arcane", "arch", "ardent", "are", "area", "argue", "arid", "april", "arab", "arctic", "athens", "austin", "bach", "baltic", - "basque", "berlin", "bible", "arise", "arm", "armful", "armpit", + "arcane", "arch", "ardent", "are", "area", "argue", "arid", "army", "aroma", "around", "arouse", "array", "arrest", "arrive", "arrow", "arson", "art", "artery", "artful", "artist", "ascent", "ashen", "ashore", "aside", "ask", "asleep", "aspect", "assay", @@ -71,6 +133,7 @@ pub const WORD_LIST: &[&str] = &[ "bare", "barely", "barge", "bark", "barley", "barn", "baron", "barrel", "barren", "basalt", "base", "basic", "basil", "basin", "basis", "basket", "bass", "bat", "batch", "bath", "baton", + "basque", "berlin", "bible", "arise", "arm", "armful", "armpit", "battle", "bay", "beach", "beacon", "beak", "beam", "bean", "bear", "beard", "beast", "beat", "beauty", "become", "bed", "beech", "beef", "beefy", "beep", "beer", "beet", "beetle", "before", @@ -87,10 +150,9 @@ pub const WORD_LIST: &[&str] = &[ "blot", "blouse", "blow", "blue", "bluff", "blunt", "blur", "blush", "boar", "board", "boast", "boat", "bodily", "body", "bogus", "boil", "bold", "bolt", "bomb", "bond", "bombay", "bonn", - "boston", "brazil", "briton", "buddha", "burma", "caesar", "cairo", - "canada", "bone", "bonnet", "bonus", "bony", "book", "boom", "boost", "boot", "booth", "booze", "border", "bore", "borrow", "bosom", "boss", "both", "bother", "bottle", "bottom", "bought", + "boston", "brazil", "briton", "buddha", "burma", "caesar", "cairo", "bounce", "bound", "bounty", "bout", "bovine", "bow", "bowel", "bowl", "box", "boy", "boyish", "brace", "brain", "brainy", "brake", "bran", "branch", "brand", "brandy", "brass", "brave", @@ -108,11 +170,11 @@ pub const WORD_LIST: &[&str] = &[ "cable", "cache", "cactus", "cage", "cake", "calf", "call", "caller", "calm", "calmly", "came", "camel", "camera", "camp", "campus", "can", "canal", "canary", "cancel", "cancer", "candid", + "canada", "bone", "bonnet", "bonus", "bony", "book", "boom", "candle", "candy", "cane", "canine", "canoe", "canopy", "canvas", "canyon", "cap", "cape", "car", "carbon", "card", "care", "career", "caress", "cargo", "carnal", "carp", "carpet", "carrot", "carry", "cart", "carl", "carol", "celtic", "chile", "china", "christ", - "congo", "cuba", "cyprus", "czech", "cartel", "case", "cash", "cask", "cast", "castle", "casual", "cat", "catch", "cater", "cattle", "caught", "causal", "cause", "cave", "cease", "celery", "cell", "cellar", "cement", "censor", "census", "cereal", "cervix", @@ -136,6 +198,7 @@ pub const WORD_LIST: &[&str] = &[ "collar", "colon", "colony", "colt", "column", "comb", "combat", "come", "comedy", "comic", "commit", "common", "compel", "comply", "concur", "cone", "confer", "consul", "convex", "convey", "convoy", + "congo", "cuba", "cyprus", "czech", "cartel", "case", "cash", "cook", "cool", "cope", "copper", "copy", "coral", "cord", "core", "cork", "corn", "corner", "corps", "corpse", "corpus", "cortex", "cosmic", "cosmos", "cost", "costly", "cosy", "cotton", "couch", @@ -153,8 +216,8 @@ pub const WORD_LIST: &[&str] = &[ "cute", "cycle", "cyclic", "cynic", "dad", "daddy", "dagger", "daily", "dairy", "daisy", "dale", "damage", "damn", "damp", "dampen", "dance", "danger", "dare", "dallas", "danish", "darwin", - "david", "delhi", "derby", "diana", "dublin", "dutch", "east", "dark", "darken", "dash", "data", "date", "dawn", "day", "dead", + "david", "delhi", "derby", "diana", "dublin", "dutch", "east", "deadly", "deaf", "deal", "dealer", "dean", "dear", "death", "debate", "debit", "debris", "debt", "debtor", "decade", "decay", "decent", "decide", "deck", "decor", "decree", "deduce", "deed", @@ -184,7 +247,6 @@ pub const WORD_LIST: &[&str] = &[ "earth", "ease", "easel", "easily", "easter", "easy", "eat", "eaten", "eater", "echo", "eddy", "edge", "edible", "eden", "edward", "eric", "essex", "europe", "eve", "exodus", "france", - "french", "friday", "edict", "edit", "editor", "eerie", "eerily", "effect", "effort", "egg", "ego", "eight", "eighth", "eighty", "either", "elbow", "elder", "eldest", "elect", "eleven", "elicit", "elite", "else", "elude", "elves", "embark", "emblem", "embryo", @@ -227,6 +289,7 @@ pub const WORD_LIST: &[&str] = &[ "foul", "found", "four", "fourth", "fox", "foyer", "frail", "frame", "franc", "frank", "fraud", "free", "freed", "freely", "freer", "freeze", "frenzy", "fresh", "friar", "fridge", "fried", + "french", "friday", "edict", "edit", "editor", "eerie", "eerily", "friend", "fright", "fringe", "frock", "frog", "from", "front", "frost", "frosty", "frown", "frozen", "frugal", "fruit", "fudge", "fuel", "fulfil", "full", "fully", "fun", "fund", "funny", "fur", @@ -234,10 +297,10 @@ pub const WORD_LIST: &[&str] = &[ "future", "fuzzy", "gadget", "gag", "gain", "gala", "galaxy", "gale", "gall", "galley", "gallon", "gallop", "gamble", "game", "gamma", "gang", "gandhi", "gaul", "gemini", "geneva", "george", - "german", "gloria", "god", "gothic", "greece", "gap", "garage", "garden", "garlic", "gas", "gasp", "gate", "gather", "gauge", "gaunt", "gave", "gay", "gaze", "gear", "geese", "gender", "gene", "genial", "genius", "genre", "gentle", "gently", "gentry", "genus", + "german", "gloria", "god", "gothic", "greece", "gap", "garage", "get", "ghetto", "ghost", "giant", "gift", "giggle", "gill", "gilt", "ginger", "girl", "give", "given", "glad", "glade", "glance", "gland", "glare", "glass", "glassy", "gleam", "glee", @@ -250,7 +313,6 @@ pub const WORD_LIST: &[&str] = &[ "gray", "grease", "greasy", "great", "greed", "greedy", "green", "greet", "grew", "grey", "grid", "grief", "grill", "grim", "grin", "grind", "greek", "hague", "haiti", "hanoi", "harry", "havana", - "hawaii", "hebrew", "henry", "hermes", "grip", "grit", "gritty", "groan", "groin", "groom", "groove", "gross", "ground", "group", "grove", "grow", "grown", "growth", "grudge", "grunt", "guard", "guess", "guest", "guide", "guild", "guilt", "guilty", "guise", @@ -261,6 +323,7 @@ pub const WORD_LIST: &[&str] = &[ "harder", "hardly", "hare", "harem", "harm", "harp", "harsh", "has", "hash", "hassle", "haste", "hasten", "hasty", "hat", "hatch", "hate", "haul", "haunt", "have", "haven", "havoc", "hawk", + "hawaii", "hebrew", "henry", "hermes", "grip", "grit", "gritty", "hazard", "haze", "hazel", "hazy", "head", "heal", "health", "heap", "hear", "heard", "heart", "hearth", "hearty", "heat", "heater", "heaven", "heavy", "heck", "hectic", "hedge", "heel", @@ -270,7 +333,6 @@ pub const WORD_LIST: &[&str] = &[ "heroic", "heroin", "hey", "heyday", "hick", "hidden", "hide", "high", "higher", "highly", "hill", "him", "hind", "hint", "hippy", "hire", "his", "hiss", "hit", "hive", "hindu", "hitler", "idaho", - "inca", "india", "indian", "iowa", "iran", "iraq", "irish", "hoard", "hoarse", "hobby", "hockey", "hold", "holder", "hole", "hollow", "holly", "holy", "home", "honest", "honey", "hood", "hook", "hope", "horn", "horny", "horrid", "horror", "horse", @@ -281,6 +343,7 @@ pub const WORD_LIST: &[&str] = &[ "icon", "idea", "ideal", "idiom", "idiot", "idle", "idly", "idol", "ignite", "ignore", "ill", "image", "immune", "impact", "imply", "import", "impose", "incest", "inch", "income", "incur", "indeed", + "inca", "india", "indian", "iowa", "iran", "iraq", "irish", "index", "indoor", "induce", "inept", "inert", "infant", "infect", "infer", "influx", "inform", "inject", "injure", "injury", "inlaid", "inland", "inlet", "inmate", "inn", "innate", "inner", @@ -292,17 +355,17 @@ pub const WORD_LIST: &[&str] = &[ "jacob", "james", "japan", "itself", "ivory", "jacket", "jade", "jaguar", "jail", "jargon", "jaw", "jazz", "jeep", "java", "jersey", "jesus", "jewish", "jim", "john", "jordan", "joseph", - "judas", "judy", "jelly", "jerky", "jest", "jet", "jewel", "job", "jock", "jockey", "join", "joint", "joke", "jolly", "jolt", "joy", "joyful", "joyous", "judge", "juice", "juicy", "jumble", "jumbo", + "judas", "judy", "jelly", "jerky", "jest", "jet", "jewel", "job", "july", "june", "kansas", "karl", "kenya", "koran", "korea", - "kuwait", "laos", "latin", "leo", "jump", "jungle", "junior", "junk", "junta", "jury", "just", "karate", "keel", "keen", "keep", "keeper", "kept", "kernel", "kettle", "key", "khaki", "kick", "kid", "kidnap", "kidney", "kill", "killer", "kin", "kind", "kindly", "king", "kiss", "kite", "kitten", "knack", "knee", "knew", "knife", "knight", "knit", "knob", "knock", "knot", "know", "known", "label", "lace", "lack", "lad", "ladder", "laden", "lady", + "kuwait", "laos", "latin", "leo", "jump", "jungle", "junior", "lagoon", "laity", "lake", "lamb", "lame", "lamp", "lance", "land", "lane", "lap", "lapse", "large", "larval", "laser", "last", "latch", "late", "lately", "latent", "later", "latest", "latter", @@ -315,7 +378,6 @@ pub const WORD_LIST: &[&str] = &[ "lessen", "lesser", "lesson", "lest", "let", "lethal", "letter", "level", "lever", "levy", "lewis", "liable", "liar", "libel", "libya", "lima", "lisbon", "liz", "london", "louvre", "lucy", - "luther", "madame", "madrid", "lice", "lick", "lid", "lie", "lied", "life", "lift", "light", "like", "likely", "limb", "lime", "limit", "limp", "line", "linear", "linen", "linger", "link", "lion", "lip", "liquid", "liquor", "list", "listen", "lit", "live", "lively", @@ -328,14 +390,15 @@ pub const WORD_LIST: &[&str] = &[ "loyal", "lucid", "luck", "lucky", "lull", "lump", "lumpy", "lunacy", "lunar", "lunch", "lung", "lure", "lurid", "lush", "lust", "lute", "luxury", "lying", "lymph", "lynch", "lyric", + "luther", "madame", "madrid", "lice", "lick", "lid", "lie", "lied", "macho", "macro", "mad", "madam", "made", "mafia", "magic", "magma", "magnet", "magnum", "maid", "maiden", "mail", "main", "mainly", "major", "make", "maker", "male", "malice", "mall", "malt", "mammal", "manage", "mane", "malta", "maria", "mars", - "mary", "maya", "mecca", "mexico", "miami", "mickey", "milan", "mania", "manic", "manner", "manor", "mantle", "manual", "manure", "many", "map", "maple", "marble", "march", "mare", "margin", "marina", "mark", "market", "marry", "marsh", "martin", "martyr", + "mary", "maya", "mecca", "mexico", "miami", "mickey", "milan", "mask", "mason", "mass", "mast", "master", "match", "mate", "matrix", "matter", "mature", "maxim", "may", "maybe", "mayor", "maze", "mead", "meadow", "meal", "mean", "meant", "meat", "medal", @@ -351,10 +414,10 @@ pub const WORD_LIST: &[&str] = &[ "mix", "moan", "moat", "mobile", "mock", "mode", "model", "modem", "modern", "modest", "modify", "module", "moist", "molar", "mole", "molten", "moment", "monaco", "monday", "moscow", "moses", - "moslem", "mrs", "munich", "muslim", "naples", "nazi", "money", "monies", "monk", "monkey", "month", "mood", "moody", "moon", "moor", "moral", "morale", "morbid", "more", "morgue", "mortal", "mortar", "mosaic", "mosque", "moss", "most", "mostly", "moth", + "moslem", "mrs", "munich", "muslim", "naples", "nazi", "money", "mother", "motion", "motive", "motor", "mould", "mount", "mourn", "mouse", "mouth", "move", "movie", "much", "muck", "mucus", "mud", "muddle", "muddy", "mule", "mummy", "murder", "murky", "murmur", @@ -365,9 +428,8 @@ pub const WORD_LIST: &[&str] = &[ "nation", "native", "nature", "nausea", "naval", "nave", "navy", "near", "nearer", "nearly", "neat", "neatly", "neck", "need", "needle", "needy", "negate", "neon", "nephew", "nepal", "newark", - "nile", "nobel", "north", "norway", "ohio", "oscar", "oslo", - "oxford", "nerve", "nest", "neural", "never", "newly", "next", "nice", "nicely", "niche", "nickel", "niece", "night", "nimble", + "nile", "nobel", "north", "norway", "ohio", "oscar", "oslo", "nine", "ninety", "ninth", "noble", "nobody", "node", "noise", "noisy", "non", "none", "noon", "nor", "norm", "normal", "nose", "nosy", "not", "note", "notice", "notify", "notion", "nought", @@ -384,10 +446,10 @@ pub const WORD_LIST: &[&str] = &[ "otter", "ought", "ounce", "our", "out", "outer", "output", "outset", "oval", "oven", "over", "overt", "owe", "owing", "owl", "own", "owner", "oxide", "oxygen", "oyster", "ozone", "pace", + "oxford", "nerve", "nest", "neural", "never", "newly", "next", "pack", "packet", "pact", "paddle", "paddy", "pagan", "page", "paid", "pain", "paint", "pair", "palace", "pale", "palm", "panel", "panic", "panama", "paris", "pascal", "paul", "peking", "peru", - "peter", "philip", "poland", "polish", "papa", "papal", "paper", "parade", "parcel", "pardon", "parent", "parish", "park", "parody", "parrot", "part", "partly", "party", "pass", "past", "paste", "pastel", "pastor", "pastry", "pat", "patch", "patent", "path", @@ -396,6 +458,7 @@ pub const WORD_LIST: &[&str] = &[ "pelvic", "pelvis", "pen", "penal", "pence", "pencil", "penis", "penny", "people", "pepper", "per", "perch", "peril", "period", "perish", "permit", "person", "pest", "petite", "petrol", "petty", + "peter", "philip", "poland", "polish", "papa", "papal", "paper", "phase", "phone", "photo", "phrase", "piano", "pick", "picket", "picnic", "pie", "piece", "pier", "pierce", "piety", "pig", "pigeon", "piggy", "pike", "pile", "pill", "pillar", "pillow", @@ -411,9 +474,8 @@ pub const WORD_LIST: &[&str] = &[ "pony", "pool", "poor", "poorly", "pop", "pope", "poppy", "pore", "pork", "port", "portal", "pose", "posh", "post", "postal", "pot", "potato", "potent", "pouch", "pound", "pour", "powder", "power", - "praise", "pray", "prayer", "preach", "prefer", "prefix", "press", "prague", "quebec", "rex", "rhine", "ritz", "robert", "roman", - "rome", "rosa", "russia", "pretty", "price", "pride", "priest", + "praise", "pray", "prayer", "preach", "prefer", "prefix", "press", "primal", "prime", "prince", "print", "prior", "prism", "prison", "privy", "prize", "probe", "profit", "prompt", "prone", "proof", "propel", "proper", "prose", "proton", "proud", "prove", "proven", @@ -450,6 +512,7 @@ pub const WORD_LIST: &[&str] = &[ "road", "roar", "roast", "rob", "robe", "robin", "robot", "robust", "rock", "rocket", "rocky", "rod", "rode", "rodent", "rogue", "role", "roll", "roof", "room", "root", "rope", "rose", "rosy", + "rome", "rosa", "russia", "pretty", "price", "pride", "priest", "rotate", "rotor", "rotten", "rouge", "rough", "round", "route", "rover", "row", "royal", "rubble", "ruby", "rudder", "rude", "rugby", "ruin", "rule", "ruler", "rumble", "rump", "run", "rune", @@ -458,7 +521,6 @@ pub const WORD_LIST: &[&str] = &[ "safe", "safely", "safer", "safety", "saga", "sage", "said", "sail", "sailor", "saint", "sake", "salad", "salary", "sale", "saline", "sahara", "sam", "saturn", "saudi", "saxon", "scot", - "seoul", "somali", "sony", "soviet", "saliva", "salmon", "saloon", "salt", "salty", "salute", "same", "sample", "sand", "sandy", "sane", "sash", "satan", "satin", "satire", "sauce", "sauna", "savage", "save", "say", "scale", "scalp", "scan", "scant", "scar", @@ -470,6 +532,7 @@ pub const WORD_LIST: &[&str] = &[ "seeing", "seek", "seem", "seize", "seldom", "select", "self", "sell", "seller", "semi", "senate", "send", "senile", "senior", "sense", "sensor", "sent", "sentry", "sequel", "serene", "serial", + "seoul", "somali", "sony", "soviet", "saliva", "salmon", "saloon", "series", "sermon", "serum", "serve", "server", "set", "settle", "seven", "severe", "sewage", "sex", "sexual", "sexy", "shabby", "shade", "shadow", "shady", "shaft", "shaggy", "shah", "shake", @@ -501,7 +564,6 @@ pub const WORD_LIST: &[&str] = &[ "sordid", "sore", "sorrow", "sorry", "sort", "soul", "sound", "soup", "sour", "source", "space", "spade", "span", "spare", "spark", "spain", "stalin", "sudan", "suez", "sunday", "sweden", - "swiss", "sydney", "syria", "taiwan", "sparse", "spasm", "spat", "spate", "speak", "spear", "speech", "speed", "speedy", "spell", "spend", "sperm", "sphere", "spice", "spicy", "spider", "spiky", "spill", "spin", "spinal", "spine", "spiral", "spirit", "spit", @@ -529,12 +591,12 @@ pub const WORD_LIST: &[&str] = &[ "swan", "swap", "swarm", "sway", "swear", "sweat", "sweaty", "sweep", "sweet", "swell", "swift", "swim", "swine", "swing", "swirl", "switch", "sword", "swore", "symbol", "synod", "syntax", + "swiss", "sydney", "syria", "taiwan", "sparse", "spasm", "spat", "syrup", "system", "table", "tablet", "taboo", "tacit", "tackle", "tact", "tactic", "tail", "tailor", "take", "tale", "talent", "talk", "tall", "tally", "tame", "tandem", "tangle", "tank", "tap", "tape", "target", "tariff", "tart", "task", "taste", "tarzan", "taurus", "tehran", "teresa", "texas", "thomas", "tibet", "tokyo", - "tom", "turk", "tasty", "tattoo", "taut", "tavern", "tax", "taxi", "tea", "teach", "teak", "team", "tear", "tease", "tech", "teeth", "tell", "temper", "temple", "tempo", "tempt", "ten", "tenant", "tend", "tender", "tendon", "tennis", "tenor", "tense", "tensor", @@ -549,6 +611,7 @@ pub const WORD_LIST: &[&str] = &[ "tile", "till", "tilt", "timber", "time", "timid", "tin", "tiny", "tip", "tissue", "title", "toad", "toast", "today", "toilet", "token", "told", "toll", "tomato", "tomb", "tonal", "tone", + "tom", "turk", "tasty", "tattoo", "taut", "tavern", "tax", "taxi", "tongue", "tonic", "too", "took", "tool", "tooth", "top", "topaz", "topic", "torch", "torque", "torso", "tort", "toss", "total", "touch", "tough", "tour", "toward", "towel", "tower", "town", @@ -562,7 +625,6 @@ pub const WORD_LIST: &[&str] = &[ "try", "tsar", "tube", "tumble", "tuna", "tundra", "tune", "tung", "tunic", "tunnel", "turban", "turf", "turn", "turtle", "tutor", "tweed", "twelve", "turkey", "uganda", "venice", "venus", "vienna", - "viking", "virgo", "warsaw", "west", "yale", "twenty", "twice", "twin", "twist", "two", "tycoon", "tying", "type", "tyrant", "ugly", "ulcer", "ultra", "umpire", "unable", "uncle", "under", "uneasy", "unfair", "unify", "union", "unique", "unit", "unite", @@ -577,6 +639,7 @@ pub const WORD_LIST: &[&str] = &[ "verb", "verbal", "verge", "verify", "verity", "verse", "versus", "very", "vessel", "vest", "veto", "via", "viable", "vicar", "vice", "victim", "victor", "video", "view", "vigil", "vile", "villa", + "viking", "virgo", "warsaw", "west", "yale", "twenty", "twice", "vine", "vinyl", "viola", "violet", "violin", "viral", "virgin", "virtue", "virus", "visa", "vision", "visit", "visual", "vital", "vivid", "vocal", "vodka", "vogue", "voice", "void", "volley", @@ -602,7 +665,6 @@ pub const WORD_LIST: &[&str] = &[ "wrist", "writ", "write", "writer", "wrong", "xerox", "yacht", "yard", "yarn", "yeah", "year", "yeast", "yellow", "yet", "yield", "yogurt", "yolk", "you", "young", "your", "yemen", "york", "zaire", - "zurich", "aback", "abbey", "abbot", "abide", "ablaze", "able", "youth", "zeal", "zebra", "zenith", "zero", "zigzag", "zinc", - "zombie", "zone", + "zombie", "zone","zurich" ]; diff --git a/tests/test_lib.rs b/tests/test_lib.rs index 82c89ee..50983eb 100644 --- a/tests/test_lib.rs +++ b/tests/test_lib.rs @@ -31,11 +31,12 @@ mod tests { #[test] fn test_words() { - let common = Common::new(); - let words = common.words(); - assert_eq!(words.words_list().len(), 4096); + let words = Words::new(); + let new_words = words.words(); + + assert_eq!(new_words.words.len(), 0); } - + #[test] fn test_default() { let common = Common::default(); diff --git a/tests/test_words.rs b/tests/test_words.rs index 207d4d0..06417c3 100644 --- a/tests/test_words.rs +++ b/tests/test_words.rs @@ -3,23 +3,77 @@ #[cfg(test)] mod tests { - use cmn::Words; + use cmn::{words::WORD_LIST, Words}; #[test] - fn test_words_list() { + fn test_empty_words_list() { let words = Words::new(); - let words_list = words.words_list(); - assert_eq!(words_list[0], "aboard"); - assert_eq!(words_list[1], "abode"); - assert_eq!(words_list[2], "abort"); + assert!(words.words_list().is_empty(), "Words list should be empty when initialized without default."); + } + + #[test] +fn test_default_words_list_order() { + let words = Words::default(); + let words_list = words.words_list(); + // Checking the first three elements to verify correct initialization and ordering + assert_eq!(words_list.len(), WORD_LIST.len(), "Default words list length should match WORD_LIST length."); + assert_eq!(words_list[0], "aboard", "Check that words list is sorted and starts with the first word."); + assert_eq!(words_list[1], "abode", "Check the second word in the sorted list."); + assert_eq!(words_list[2], "abort", "Check the third word in the sorted list."); +} + + #[test] + fn test_add_word_and_contains() { + let mut words = Words::new(); + words.add_word("example"); + assert!(words.contains("example"), "Word 'example' should be found after adding."); + assert!(!words.contains("test"), "Word 'test' should not be found if not added."); + } + + #[test] + fn test_word_count() { + let mut words = Words::new(); + words.add_word("test"); + words.add_word("check"); + words.add_word("rust"); + assert_eq!(words.count(), 3, "Count should be equal to the number of unique words added."); } #[test] - fn test_default_words() { - let words = Words {}; + fn test_duplicates_not_added() { + let mut words = Words::new(); + words.add_word("duplicate"); + words.add_word("duplicate"); + assert_eq!(words.count(), 1, "Duplicates should not increase the count."); + } + + #[test] + fn test_clear_words() { + let mut words = Words::default(); + assert!(!words.words_list().is_empty(), "Words list should not be empty after initialization with default."); + words.clear(); + assert!(words.words_list().is_empty(), "Words list should be empty after calling clear()."); + } + + #[test] + fn test_remove_word() { + let mut words = Words::new(); + words.add_word("remove"); + assert!(words.contains("remove"), "Word 'remove' should be found after adding."); + assert!(words.remove_word("remove"), "remove_word() should return true if the word was removed."); + assert!(!words.contains("remove"), "Word 'remove' should not be found after removal."); + assert!(!words.remove_word("nonexistent"), "remove_word() should return false for a nonexistent word."); + } + + #[test] + fn test_words_list_order() { + let mut words = Words::new(); + words.add_word("zebra"); + words.add_word("apple"); + words.add_word("monkey"); let words_list = words.words_list(); - assert_eq!(words_list[0], "aboard"); - assert_eq!(words_list[1], "abode"); - assert_eq!(words_list[2], "abort"); + assert_eq!(words_list[0], "apple", "Words list should be sorted alphabetically."); + assert_eq!(words_list[1], "monkey", "Words list should be sorted alphabetically."); + assert_eq!(words_list[2], "zebra", "Words list should be sorted alphabetically."); } -} +} \ No newline at end of file diff --git a/xtask/Cargo.toml b/xtask/Cargo.toml deleted file mode 100644 index 1f83fab..0000000 --- a/xtask/Cargo.toml +++ /dev/null @@ -1,12 +0,0 @@ -[package] -name = "xtask" -version = "0.1.0" -edition = "2021" - -[dependencies] -anyhow = "1.0.71" -xtaskops = "0.4.2" - -[[bin]] -name = "xtask" -path = "src/main.rs" diff --git a/xtask/src/main.rs b/xtask/src/main.rs deleted file mode 100644 index c58cdf1..0000000 --- a/xtask/src/main.rs +++ /dev/null @@ -1,13 +0,0 @@ -//! This is the main entry point for the xtask crate. -//! -//! The `main()` function serves as the starting point of the executable. -//! It returns a `Result<(), anyhow::Error>`, indicating success or failure. -//! The `xtaskops::tasks::main()` function is called to perform the main tasks. -//! -//! # Errors -//! -//! If an error occurs during the execution of the tasks, an `anyhow::Error` is returned. - -fn main() -> Result<(), anyhow::Error> { - xtaskops::tasks::main() -} From 8102cfbef8ed5d9908ef42471633cf5fe639801d Mon Sep 17 00:00:00 2001 From: Sebastien Rousseau Date: Sat, 11 May 2024 09:04:57 +0100 Subject: [PATCH 6/7] fix(cmn): :thread: fix cargo bench --- benches/criterion.rs | 10 +++++----- src/lib.rs | 15 +++++++++------ src/words.rs | 14 ++++++++++---- 3 files changed, 24 insertions(+), 15 deletions(-) diff --git a/benches/criterion.rs b/benches/criterion.rs index 6e54440..7ae9427 100644 --- a/benches/criterion.rs +++ b/benches/criterion.rs @@ -13,28 +13,28 @@ pub use cmn::Common; pub use cmn::Constants; pub use cmn::Words; +#[allow(unused_results)] fn bench_cmn(c: &mut Criterion) { c.bench_function("common", |b| { b.iter(|| { let common = black_box(Common::default()); black_box(common.constants()); black_box(common.words()); - }); + }) }); } +#[allow(unused_results)] fn bench_words(c: &mut Criterion) { c.bench_function("Words::new", |b| { b.iter(|| { - let words = black_box(Words::new()); - let _ = black_box(words.words_list()); + let _words = black_box(Words::new()); }) }); c.bench_function("Words::default", |b| { b.iter(|| { - let words = black_box(Words::default()); - let _ = black_box(words.words_list()); + let _words = black_box(Words::default()); }) }); } diff --git a/src/lib.rs b/src/lib.rs index c48c4c1..b227896 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -166,12 +166,15 @@ impl Common { let words_data = self .fields .get("words") - .expect("Words data not found in JSON") - .as_array() - .expect("Words data is not an array") - .iter() - .map(|word_value| word_value.as_str().unwrap().to_string()) - .collect::>(); // Add type annotation here + .map(|words_array| { + words_array + .as_array() + .expect("Words data is not an array") + .iter() + .map(|word_value| word_value.as_str().unwrap().to_string()) + .collect::>() + }) + .unwrap_or_default(); // Add this line Words { words: HashSet::from_iter(words_data), diff --git a/src/words.rs b/src/words.rs index bc15202..b12d3fb 100644 --- a/src/words.rs +++ b/src/words.rs @@ -82,11 +82,17 @@ impl Default for Words { /// This method is automatically called when creating a new instance of `Words` /// using `Words::default()`. fn default() -> Self { - let mut words = Words::new(); - for word in WORD_LIST.iter() { - words.add_word(word); + let mut sorted_words: Vec = WORD_LIST + .iter() + .map(|&word| word.to_owned()) + .collect(); + + sorted_words.sort_unstable(); + sorted_words.dedup(); + + Words { + words: sorted_words.into_iter().collect(), } - words } } From b896e6b2c20d8db6f57a57eda9145c86b4608caa Mon Sep 17 00:00:00 2001 From: Sebastien Rousseau Date: Sat, 11 May 2024 15:32:04 +0100 Subject: [PATCH 7/7] test(cmn): :white_check_mark: add macros unit tests and reformatting --- README.md | 150 +++--- benches/criterion.rs | 2 +- src/lib.rs | 68 ++- src/macros.rs | 20 + src/words.rs | 1029 +++++++++++++++++++++--------------------- tests/test_lib.rs | 4 +- tests/test_macros.rs | 90 +++- tests/test_words.rs | 86 +++- 8 files changed, 771 insertions(+), 678 deletions(-) diff --git a/README.md b/README.md index f3ce355..8dd78e7 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ alt="Common (CMN) logo" height="261" width="261" align="right" /> A Rust library for accessing a collection of mathematical and cryptographic constants -*Part of the [Mini Functions][0] family of libraries.* +*Part of the [Mini Functions][00] family of libraries.*
@@ -17,9 +17,9 @@ A Rust library for accessing a collection of mathematical and cryptographic cons ![Common (CMN) Banner][banner] -[![Made With Rust][made-with-rust-badge]][14] [![Crates.io][crates-badge]][8] [![Lib.rs][libs-badge]][10] [![Docs.rs][docs-badge]][9] [![License][license-badge]][2] [![Codecov][codecov-badge]][15] +[![Made With Rust][made-with-rust-badge]][13] [![Crates.io][crates-badge]][08] [![Lib.rs][libs-badge]][10] [![Docs.rs][docs-badge]][09] [![License][license-badge]][02] [![Codecov][codecov-badge]][14] -β€’ [Website][1] β€’ [Documentation][9] β€’ [Report Bug][4] β€’ [Request Feature][4] β€’ [Contributing Guidelines][5] +β€’ [Website][01] β€’ [Documentation][09] β€’ [Report Bug][04] β€’ [Request Feature][04] β€’ [Contributing Guidelines][05]
@@ -37,9 +37,9 @@ The `Common (CMN)` uses the `serde` crate to serialize and deserialize the data. The library has three modules: -- **Macros**: This module contains functions for generating macros that can be used to access the constants. -- **Constants**: This module contains the Constants structure, which provides a collection of constant values that are used throughout the library. -- **Words**: This module contains the Words structure, which provides a collection of words that are used throughout the library. +- **Macros**: This module contains functions for generating macros that can be used to access the constants and words. +- **Constants**: This module contains the `Constants` structure, which provides a collection of constant values that are used throughout the library. +- **Words**: This module contains the `Words` structure, which provides a collection of words that are used throughout the library. ### Mathematical and Cryptographic Constants @@ -47,22 +47,34 @@ The following table lists the most important mathematical and cryptographic cons | Constants | Description | Example | | --- | --- | --- | -| AVOGADRO | Avogadro's constant is the number of atoms or molecules in one mole of a substance. | The number of atoms in 12 grams of carbon-12 is 6.02214076 Γ— 10^23. This can be used to calculate the number of atoms or molecules in a given sample. | -| BOLTZMANN | Boltzmann's constant is the physical constant relating the temperature of a system to the average kinetic energy of its constituent particles. | The kinetic energy of an atom at room temperature is about 2.0 Γ— 10^-21 joules. This can be used to calculate the temperature of a system, or to calculate the average kinetic energy of its particles. | -| EULER | Euler's constant is a mathematical constant approximately equal to 2.71828. | The sum of the infinite series 1 + 1/2 + 1/3 + ... is equal to Euler's constant, e. This can be used to calculate the sum of an infinite series, or to calculate the logarithm of a number. | -| GAMMA | The gamma constant is a mathematical constant approximately equal to 0.57721. | The gamma function of 2 is equal to 1. This can be used to calculate the gamma function of a number, or to calculate the factorial of a number. | +| APERY | ApΓ©ry's constant, which is the sum of the reciprocals of the positive cubes. `ΞΆ(3) β‰ˆ 1.2020569032` | Used in various mathematical calculations and series approximations. | +| AVOGADRO | Avogadro's constant is the number of atoms or molecules in one mole of a substance. `N_A β‰ˆ 6.02214076 x 10^23 mol^-1` | The number of atoms in 12 grams of carbon-12 is 6.02214076 Γ— 10^23. This can be used to calculate the number of atoms or molecules in a given sample. | +| BOLTZMANN | Boltzmann's constant is the physical constant relating the temperature of a system to the average kinetic energy of its constituent particles. `k_B β‰ˆ 1.380648 x 10^-23 J K^-1` | The kinetic energy of an atom at room temperature is about 2.0 Γ— 10^-21 joules. This can be used to calculate the temperature of a system, or to calculate the average kinetic energy of its particles. | +| CATALAN | Catalan's constant, which is the sum of the alternating harmonic series. `C β‰ˆ 0.915965594177219` | Used in various mathematical calculations and series approximations. | +| COULOMB | Coulomb's constant, which is the proportionality constant in Coulomb's law. `k_e β‰ˆ 8.9875517923` x 10^9 N m^2 C^-2 | Used in calculations related to electrostatic forces and electric fields. | +| EULER | Euler's constant is a mathematical constant approximately equal to 2.71828. `e β‰ˆ 2.7182818284590452353602874713527` | The sum of the infinite series 1 + 1/2 + 1/3 + ... is equal to Euler's constant, e. This can be used to calculate the sum of an infinite series, or to calculate the logarithm of a number. | +| FARADAY | Faraday constant, which represents the amount of electric charge carried by one mole of electrons. `F β‰ˆ 96485.33212 C mol^-1` | Used in calculations related to electrochemistry and electrolysis. | +| GAMMA | The gamma constant is a mathematical constant approximately equal to 0.57721. `Ξ³ β‰ˆ 0.5772156649015329` | The gamma function of 2 is equal to 1. This can be used to calculate the gamma function of a number, or to calculate the factorial of a number. | +| GAS_CONSTANT | The gas constant, which relates the energy scale to the temperature scale in the ideal gas law. `R β‰ˆ 8.314462618 J mol^-1 K^-1` | Used in calculations related to the behavior of gases and thermodynamics. | +| GLAISHER_KINKELIN | Glaisher-Kinkelin constant, which arises in the asymptotic expansion of the Barnes G-function. `A β‰ˆ 1.2824271291` | Used in various mathematical calculations and series approximations. | +| GRAVITATIONAL_CONSTANT | The gravitational constant, which is the proportionality constant in Newton's law of universal gravitation. `G β‰ˆ 6.67430 x 10^-11 m^3 kg^-1 s^-2` | Used in calculations related to gravitational forces and celestial mechanics. | | HASH_ALGORITHM | The hash algorithm used to generate the hash. The default is Blake3. | The hash of the string "Hello, world!" is 5eb63bbbe01eeed093cb22bb8f5acdc32790160b123138d53f2173b8d3dc3eee. This can be used to verify the integrity of data, or to create a unique identifier for a file. | -| HASH_COST | The cost of the hash. | The hash cost of Blake3 is 2^128. This can be used to determine how secure a hash algorithm is. | +| HASH_COST | The cost of the hash. | The hash cost of Blake3 is `2^128`. This can be used to determine how secure a hash algorithm is. | | HASH_LENGTH | The length of the hash. | The hash length of Blake3 is 32 bytes. This can be used to determine how much space is required to store the hash output. | -| PHI | The golden ratio is a number approximately equal to 1.618033988749895. | The golden ratio can be used to create a symmetrical design, or a design that is pleasing to the eye. | -| Pi (Ο€) | Pi is the ratio of a circle's circumference to its diameter. | The circumference of a circle with a radius of 1 is equal to pi. This can be used to calculate the circumference, area, and volume of circles, spheres, and other geometric shapes. | -| PLANCK | Planck's constant is a physical constant that is approximately equal to 6.62607015 Γ— 10^βˆ’34 joule seconds. | The energy of a photon of light with a wavelength of 500 nanometers is equal to Planck's constant multiplied by the frequency of the light. This can be used to calculate the energy of photons and other elementary particles. | -| SILVER_RATIO | The silver ratio is a number approximately equal to 1.414213562373095. | The silver ratio can be used to create a symmetrical design, or a design that is pleasing to the eye. | -| SPECIAL_CHARS | A list of special characters. | The special characters are: !@#$%^&*()_+-={}[]|\:;"'<>,.? | -| SQRT2 | The square root of 2 is a number approximately equal to 1.414213562373095. | The area of a circle with a radius of 1 is equal to the square root of 2. This can be used to calculate the area and volume of circles, spheres, and other geometric shapes. | -| SQRT3 | The square root of 3 is a number approximately equal to 1.732050807568877. | The area of a circle with a radius of 1 is equal to the square root of 3. This can be used to calculate the area and volume of circles -| SQRT5 | The square root of 5 is a number approximately equal to 2.23606797749979. | The area of a circle with a radius of 1 is equal to the square root of 5. | -| TAU | Tau is a number approximately equal to 6.283185307179586. | The circumference of a circle with a radius of 1 is equal to tau. | +| KHINCHIN | Khinchin's constant, which appears in the theory of continued fractions. `K β‰ˆ 2.6854520010` | Used in various mathematical calculations and series approximations. | +| PHI | The golden ratio is a number approximately equal to 1.618033988749895. `Ο† = (1 + √5) / 2 β‰ˆ 1.6180339887498948482045868343656` | The golden ratio can be used to create a symmetrical design, or a design that is pleasing to the eye. | +| Pi (Ο€) | Pi is the ratio of a circle's circumference to its diameter. `Ο€ β‰ˆ 3.14159265358979323846264338327950288` | The circumference of a circle with a radius of 1 is equal to pi. This can be used to calculate the circumference, area, and volume of circles, spheres, and other geometric shapes. | +| PLANCK | Planck's constant, which relates the energy of a photon to its frequency. `h β‰ˆ 6.62607015 x 10^-34 J s` | The energy of a photon of light with a wavelength of 500 nanometers is equal to Planck's constant multiplied by the frequency of the light. This can be used to calculate the energy of photons and other elementary particles. | +| PLANCK_REDUCED | Planck's reduced constant, which is Planck's constant divided by 2Ο€. `Δ§ = h / (2Ο€) β‰ˆ 1.054571817 x 10^-34 J s` | Used in quantum mechanics and related calculations. | +| SILVER_RATIO | The silver ratio is one of the silver means. `Ξ΄_s = 1 + √2 β‰ˆ 2.4142135623730950488016887242097` | The silver ratio can be used to create a symmetrical design, or a design that is pleasing to the eye. | +| SPEED_OF_LIGHT | The speed of light in vacuum. `c β‰ˆ 299792458 m s^-1` | Used in calculations related to relativity and electromagnetic phenomena. | +| SPECIAL_CHARS | A set of special characters. | The special characters are: !@#$%^&*()_+-={}[]|\:;"'<>,.?` | +| SQRT2 | The square root of 2. `√2 β‰ˆ 1.4142135623730950488016887242097` | The area of a circle with a radius of 1 is equal to the square root of 2. This can be used to calculate the area and volume of circles, spheres, and other geometric shapes. | +| SQRT3 | The square root of 3. `√3 β‰ˆ 1.7320508075688772935274463415059` | The area of a circle with a radius of 1 is equal to the square root of 3. This can be used to calculate the area and volume of circles. | +| SQRT5 | The square root of 5. `√5 β‰ˆ 2.23606797749979` | The area of a circle with a radius of 1 is equal to the square root of 5. | +| TAU | The circle constant, which is the ratio of a circle's circumference to its radius. `Ο„ = 2Ο€ β‰ˆ 6.28318530717958647692528676655900577` | The circumference of a circle with a radius of 1 is equal to tau. | +| VACUUM_PERMEABILITY | The vacuum permeability, which relates magnetic induction to magnetic field strength. `ΞΌ_0 β‰ˆ 1.25663706212 x 10^-6 N A^-2` | Used in calculations related to electromagnetism and magnetic fields. | +| VACUUM_PERMITTIVITY | The vacuum permittivity, which relates electric displacement to electric field strength. `Ξ΅_0 β‰ˆ 8.8541878128 x 10^-12 F m^-1` | Used in calculations related to electromagnetism and electric fields. | ## Getting Started πŸš€ @@ -70,7 +82,7 @@ It takes just a few minutes to get up and running with `Common (CMN)`. ### Installation -To install `Common (CMN)`, you need to have the Rust toolchain installed on your machine. You can install the Rust toolchain by following the instructions on the [Rust website][14]. +To install `Common (CMN)`, you need to have the Rust toolchain installed on your machine. You can install the Rust toolchain by following the instructions on the [Rust website][13]. Once you have the Rust toolchain installed, you can install `Common (CMN)` using the following command: @@ -78,62 +90,19 @@ Once you have the Rust toolchain installed, you can install `Common (CMN)` using cargo install cmn ``` -You can then run the help command to see the available options: - -```shell -cmn --help -``` - ### Requirements -The minimum supported Rust toolchain version is currently Rust **1.69.0** or later (stable). It is recommended that you install the latest stable version of Rust. +The minimum supported Rust toolchain version is currently Rust **1.60** or later (stable). It is recommended that you install the latest stable version of Rust. ### Platform support -`Common (CMN)` is supported and tested on the following platforms: +`cmn` supports a variety of CPU architectures. It is supported and tested on MacOS, Linux, and Windows. -#### Tier 1 platforms πŸ† - -| Operating System | Target | Description | -| --- | --- | --- | -| Linux | aarch64-unknown-linux-gnu | 64-bit Linux systems on ARM architecture | -| Linux | i686-unknown-linux-gnu | 32-bit Linux (kernel 3.2+, glibc 2.17+) | -| Linux | x86_64-unknown-linux-gnu | 64-bit Linux (kernel 2.6.32+, glibc 2.11+) | -| macOS | x86_64-apple-darwin | 64-bit macOS (10.7 Lion or later) | -| Windows | i686-pc-windows-gnu | 32-bit Windows (7 or later) | -| Windows | i686-pc-windows-msvc | 32-bit Windows (7 or later) | -| Windows | x86_64-pc-windows-gnu | 64-bit Windows (7 or later) | -| Windows | x86_64-pc-windows-msvc | 64-bit Windows (7 or later) | - -#### Tier 2 platforms πŸ₯ˆ - -| Operating System | Target | Description | -| --- | --- | --- | -| 64-bit Linux | x86_64-unknown-linux-musl | 64-bit Linux (kernel 2.6.32+, musl libc) | -| ARM64 Linux | aarch64-unknown-linux-musl | 64-bit Linux systems on ARM architecture | -| ARM64 macOS | aarch64-apple-darwin | 64-bit macOS on Apple Silicon | -| ARM64 Windows | aarch64-pc-windows-msvc | 64-bit Windows (aarch64-pc-windows-msvc) | -| ARMv6 Linux | arm-unknown-linux-gnueabi | ARMv6 Linux (kernel 3.2, glibc 2.17) | -| ARMv6 Linux, hardfloat | arm-unknown-linux-gnueabihf | ARMv7 Linux, hardfloat (kernel 3.2, glibc 2.17) | -| ARMv7 Linux, hardfloat | armv7-unknown-linux-gnueabihf | ARMv7 Linux, hardfloat (kernel 3.2, glibc 2.17) | -| FreeBSD | x86_64-unknown-freebsd | 64-bit FreeBSD on x86-64 | -| MIPS (LE) Linux | mipsel-unknown-linux-gnu | MIPSel Linux (kernel 2.6.32+, glibc 2.11+) | -| MIPS Linux | mips-unknown-linux-gnu | MIPS Linux (kernel 2.6.32+, glibc 2.11+) | -| MIPS64 (LE) Linux | mips64el-unknown-linux-gnuabi64 | MIPS64el Linux (kernel 2.6.32+, glibc 2.11+) | -| MIPS64 Linux | mips64-unknown-linux-gnuabi64 | MIPS64 Linux (kernel 2.6.32+, glibc 2.11+) | -| NetBSD | x86_64-unknown-netbsd | 64-bit NetBSD on x86-64 | -| PowerPC Linux | powerpc-unknown-linux-gnu | PowerPC Linux (kernel 3.2, glibc 2.17) | -| PPC64 Linux | powerpc64-unknown-linux-gnu | PowerPC64 Linux (kernel 3.2, glibc 2.17) | -| PPC64LE Linux | powerpc64le-unknown-linux-gnu | PowerPC64le Linux (kernel 3.2, glibc 2.17) | -| RISC-V Linux | riscv64gc-unknown-linux-gnu | RISC-V Linux (kernel 3.2, glibc 2.17) | -| S390x Linux | s390x-unknown-linux-gnu | s390x Linux (kernel 3.2, glibc 2.17) | - -The [GitHub Actions][11] shows the platforms in which the `Common (CMN)` library tests are run. ### Documentation -> ℹ️ **Info:** Please check out our [website][1] for more information. -You can find our documentation on [docs.rs][9], [lib.rs][10] and [crates.io][8]. +> ℹ️ **Info:** Please check out our [website][01] for more information. +You can find our documentation on [docs.rs][09], [lib.rs][10] and [crates.io][08]. ## Usage πŸ“– @@ -163,45 +132,44 @@ cargo run --example cmn ## Semantic Versioning Policy πŸš₯ -For transparency into our release cycle and in striving to maintain backward compatibility, `Common (CMN)` follows [semantic versioning][7]. +For transparency into our release cycle and in striving to maintain backward compatibility, `Common (CMN)` follows [semantic versioning][07]. ## License πŸ“ -The project is licensed under the terms of both the MIT license and the Apache License (Version 2.0). +`Common (CMN)`is distributed under the terms of both the MIT license and the +Apache License (Version 2.0). -- [Apache License, Version 2.0][2] -- [MIT license][3] +See [LICENSE-APACHE][02] and [LICENSE-MIT][03] for details. ## Contribution 🀝 -We welcome all people who want to contribute. Please see the [contributing instructions][5] for more information. +We welcome all people who want to contribute. Please see the [contributing instructions][05] for more information. -Contributions in any form (issues, pull requests, etc.) to this project must adhere to the [Rust's Code of Conduct][12]. +Contributions in any form (issues, pull requests, etc.) to this project must adhere to the [Rust's Code of Conduct][11]. Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions. ## Acknowledgements πŸ’™ -A big thank you to all the awesome contributors of the [Common (CMN) Library][6] for their help and support. +A big thank you to all the awesome contributors of the [Common (CMN) Library][06] for their help and support. -A special thank you goes to the [Rust Reddit][13] community for providing a lot of useful suggestions on how to improve this project. +A special thank you goes to the [Rust Reddit][12] community for providing a lot of useful suggestions on how to improve this project. -[0]: https://cmnlib.com/ "MiniFunctions" -[1]: https://cmnlib.one "Common (CMN) Library Website" -[2]: https://opensource.org/license/apache-2-0/ "Apache License, Version 2.0" -[3]: https://opensource.org/licenses/MIT "MIT license" -[4]: https://github.com/sebastienrousseau/cmn/issues "Issues" -[5]: https://github.com/sebastienrousseau/cmn/blob/main/CONTRIBUTING.md "Contributing Instructions" -[6]: https://github.com/sebastienrousseau/cmn/graphs/contributors "Contributors" -[7]: http://semver.org/ "Semantic Versioning" -[8]: https://crates.io/crates/cmn "Crates.io" -[9]: https://docs.rs/cmn "Docs.rs" +[00]: https://cmnlib.com/ "MiniFunctions" +[01]: https://cmnlib.one "Common (CMN) Library Website" +[02]: https://opensource.org/license/apache-2-0/ "Apache License, Version 2.0" +[03]: https://opensource.org/licenses/MIT "MIT license" +[04]: https://github.com/sebastienrousseau/cmn/issues "Issues" +[05]: https://github.com/sebastienrousseau/cmn/blob/main/CONTRIBUTING.md "Contributing Instructions" +[06]: https://github.com/sebastienrousseau/cmn/graphs/contributors "Contributors" +[07]: http://semver.org/ "Semantic Versioning" +[08]: https://crates.io/crates/cmn "Crates.io" +[09]: https://docs.rs/cmn "Docs.rs" [10]: https://lib.rs/crates/cmn "Lib.rs" -[11]: https://github.com/sebastienrousseau/cmn/actions "GitHub Actions" -[12]: https://www.rust-lang.org/policies/code-of-conduct "Rust's Code of Conduct" -[13]: https://reddit.com/r/rust "Rust Reddit" -[14]: https://www.rust-lang.org "The Rust Programming Language" -[15]: https://codecov.io/gh/sebastienrousseau/cmn "Codecov" +[11]: https://www.rust-lang.org/policies/code-of-conduct "Rust's Code of Conduct" +[12]: https://reddit.com/r/rust "Rust Reddit" +[13]: https://www.rust-lang.org "The Rust Programming Language" +[14]: https://codecov.io/gh/sebastienrousseau/cmn "Codecov" [banner]: https://kura.pro/cmn/images/titles/title-cmn.svg 'Common (CMN) banner' [codecov-badge]: https://img.shields.io/codecov/c/github/sebastienrousseau/cmn?style=for-the-badge&token=0FZQGHLMOP 'Codecov' diff --git a/benches/criterion.rs b/benches/criterion.rs index 7ae9427..0f30e3a 100644 --- a/benches/criterion.rs +++ b/benches/criterion.rs @@ -40,4 +40,4 @@ fn bench_words(c: &mut Criterion) { } criterion_group!(benches, bench_cmn, bench_words); -criterion_main!(benches); \ No newline at end of file +criterion_main!(benches); diff --git a/src/lib.rs b/src/lib.rs index b227896..05bb732 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -38,26 +38,37 @@ //! The following table lists the most important mathematical and cryptographic constants available in the `Common (CMN)` library: //! //!| Constants | Description | Example | -//!| --- | --- | --- | -//!| AVOGADRO | Avogadro's constant is the number of atoms or molecules in one mole of a substance. | The number of atoms in 12 grams of carbon-12 is 6.02214076 Γ— 10^23. This can be used to calculate the number of atoms or molecules in a given sample. | -//!| BOLTZMANN | Boltzmann's constant is the physical constant relating the temperature of a system to the average kinetic energy of its constituent particles. | The kinetic energy of an atom at room temperature is about 2.0 Γ— 10^-21 joules. This can be used to calculate the temperature of a system, or to calculate the average kinetic energy of its particles. | -//!| EULER | Euler's constant is a mathematical constant approximately equal to 2.71828. | The sum of the infinite series 1 + 1/2 + 1/3 + ... is equal to Euler's constant, e. This can be used to calculate the sum of an infinite series, or to calculate the logarithm of a number. | -//!| GAMMA | The gamma constant is a mathematical constant approximately equal to 0.57721. | The gamma function of 2 is equal to 1. This can be used to calculate the gamma function of a number, or to calculate the factorial of a number. | +//!| -- | -- | -- | +//!| APERY | ApΓ©ry's constant, is the sum of the reciprocals of the positive cubes.
`ΞΆ(3) β‰ˆ 1.2020569032` | Used in various mathematical calculations and series approximations. | +//!| AVOGADRO | Avogadro's constant is the number of atoms or molecules in one mole of a substance.
`N_A β‰ˆ 6.02214076 x 10^23 mol^-1` | The number of atoms in 12 grams of carbon-12 is 6.02214076 Γ— 10^23. This can be used to calculate the number of atoms or molecules in a given sample. | +//!| BOLTZMANN | Boltzmann's constant is the physical constant relating the temperature of a system to the average kinetic energy of its constituent particles.
`k_B β‰ˆ 1.380648 x 10^-23 J K^-1` | The kinetic energy of an atom at room temperature is about 2.0 Γ— 10^-21 joules. This can be used to calculate the temperature of a system, or to calculate the average kinetic energy of its particles. | +//!| CATALAN | Catalan's constant, is the sum of the alternating harmonic series.
`C β‰ˆ 0.915965594177219` | Used in various mathematical calculations and series approximations. | +//!| COULOMB | Coulomb's constant, is the proportionality constant in Coulomb's law.
`k_e β‰ˆ 8.9875517923` x 10^9 N m^2 C^-2 | Used in calculations related to electrostatic forces and electric fields. | +//!| EULER | Euler's constant is a mathematical constant approximately equal to 2.71828.
`e β‰ˆ 2.7182818284590452353602874713527` | The sum of the infinite series 1 + 1/2 + 1/3 + ... is equal to Euler's constant, e. This can be used to calculate the sum of an infinite series, or to calculate the logarithm of a number. | +//!| FARADAY | Faraday constant, which represents the amount of electric charge carried by one mole of electrons.
`F β‰ˆ 96485.33212 C mol^-1` | Used in calculations related to electrochemistry and electrolysis. | +//!| GAMMA | The gamma constant is a mathematical constant approximately equal to 0.57721.
`Ξ³ β‰ˆ 0.5772156649015329` | The gamma function of 2 is equal to 1. This can be used to calculate the gamma function of a number, or to calculate the factorial of a number. | +//!| GAS_CONSTANT | The gas constant, which relates the energy scale to the temperature scale in the ideal gas law.
`R β‰ˆ 8.314462618 J mol^-1 K^-1` | Used in calculations related to the behavior of gases and thermodynamics. | +//!| GLAISHER_KINKELIN | Glaisher-Kinkelin constant, which arises in the asymptotic expansion of the Barnes G-function.
`A β‰ˆ 1.2824271291` | Used in various mathematical calculations and series approximations. | +//!| GRAVITATIONAL_CONSTANT | The gravitational constant, is the proportionality constant in Newton's law of universal gravitation.
`G β‰ˆ 6.67430 x 10^-11 m^3 kg^-1 s^-2` | Used in calculations related to gravitational forces and celestial mechanics. | //!| HASH_ALGORITHM | The hash algorithm used to generate the hash. The default is Blake3. | The hash of the string "Hello, world!" is 5eb63bbbe01eeed093cb22bb8f5acdc32790160b123138d53f2173b8d3dc3eee. This can be used to verify the integrity of data, or to create a unique identifier for a file. | -//!| HASH_COST | The cost of the hash. | The hash cost of Blake3 is 2^128. This can be used to determine how secure a hash algorithm is. | +//!| HASH_COST | The cost of the hash. | The hash cost of Blake3 is
`2^128`. This can be used to determine how secure a hash algorithm is. | //!| HASH_LENGTH | The length of the hash. | The hash length of Blake3 is 32 bytes. This can be used to determine how much space is required to store the hash output. | -//!| PHI | The golden ratio is a number approximately equal to 1.618033988749895. | The golden ratio can be used to create a symmetrical design, or a design that is pleasing to the eye. | -//!| PI | Pi is the ratio of a circle's circumference to its diameter. | The circumference of a circle with a radius of 1 is equal to pi. This can be used to calculate the circumference, area, and volume of circles, spheres, and other geometric shapes. | -//!| PLANCK | Planck's constant is a physical constant that is approximately equal to 6.62607015 Γ— 10^βˆ’34 joule seconds. | The energy of a photon of light with a wavelength of 500 nanometers is equal to Planck's constant multiplied by the frequency of the light. This can be used to calculate the energy of photons and other elementary particles. | -//!| SILVER_RATIO | The silver ratio is a number approximately equal to 1.414213562373095. | The silver ratio can be used to create a symmetrical design, or a design that is pleasing to the eye. | -//!| SPECIAL_CHARS | A list of special characters. | The special characters are: !@#$%^&*()_+-={}[]|\:;"'<>,.? | -//!| SQRT2 | The square root of 2 is a number approximately equal to 1.414213562373095. | The area of a circle with a radius of 1 is equal to the square root of 2. This can be used to calculate the area and volume of circles, spheres, and other geometric shapes. | -//!| SQRT3 | The square root of 3 is a number approximately equal to 1.732050807568877. | The area of a circle with a radius of 1 is equal to the square root of 3. This can be used to calculate the area and volume of circles -//!| SQRT5 | The square root of 5 is a number approximately equal to 2.23606797749979. | The area of a circle with a radius of 1 is equal to the square root of 5. | -//!| TAU | Tau is a number approximately equal to 6.283185307179586. | The circumference of a circle with a radius of 1 is equal to tau. | -//! -//! The following table lists the dictionaries available in the Common -//! library. +//!| KHINCHIN | Khinchin's constant, which appears in the theory of continued fractions.
`K β‰ˆ 2.6854520010` | Used in various mathematical calculations and series approximations. | +//!| PHI | The golden ratio is a number approximately equal to 1.618033988749895.
`Ο† = (1 + √5) / 2 β‰ˆ 1.6180339887498948482045868343656` | The golden ratio can be used to create a symmetrical design, or a design that is pleasing to the eye. | +//!| Pi (Ο€) | Pi is the ratio of a circle's circumference to its diameter.
`Ο€ β‰ˆ 3.14159265358979323846264338327950288` | The circumference of a circle with a radius of 1 is equal to pi. This can be used to calculate the circumference, area, and volume of circles, spheres, and other geometric shapes. | +//!| PLANCK | Planck's constant, which relates the energy of a photon to its frequency.
`h β‰ˆ 6.62607015 x 10^-34 J s` | The energy of a photon of light with a wavelength of 500 nanometers is equal to Planck's constant multiplied by the frequency of the light. This can be used to calculate the energy of photons and other elementary particles. | +//!| PLANCK_REDUCED | Planck's reduced constant, is Planck's constant divided by 2Ο€.
`Δ§ = h / (2Ο€) β‰ˆ 1.054571817 x 10^-34 J s` | Used in quantum mechanics and related calculations. | +//!| SILVER_RATIO | The silver ratio is one of the silver means.
`Ξ΄_s = 1 + √2 β‰ˆ 2.4142135623730950488016887242097` | The silver ratio can be used to create a symmetrical design, or a design that is pleasing to the eye. | +//!| SPEED_OF_LIGHT | The speed of light in vacuum.
`c β‰ˆ 299792458 m s^-1` | Used in calculations related to relativity and electromagnetic phenomena. | +//!| SPECIAL_CHARS | A set of special characters. | The special characters are: !@#$%^&*()_+-={}[]|\:;"'<>,.?` | +//!| SQRT2 | The square root of 2.
`√2 β‰ˆ 1.4142135623730950488016887242097` | The area of a circle with a radius of 1 is equal to the square root of 2. This can be used to calculate the area and volume of circles, spheres, and other geometric shapes. | +//!| SQRT3 | The square root of 3.
`√3 β‰ˆ 1.7320508075688772935274463415059` | The area of a circle with a radius of 1 is equal to the square root of 3. This can be used to calculate the area and volume of circles. | +//!| SQRT5 | The square root of 5.
`√5 β‰ˆ 2.23606797749979` | The area of a circle with a radius of 1 is equal to the square root of 5. | +//!| TAU | The circle constant, is the ratio of a circle's circumference to its radius.
`Ο„ = 2Ο€ β‰ˆ 6.28318530717958647692528676655900577` | The circumference of a circle with a radius of 1 is equal to tau. | +//!| VACUUM_PERMEABILITY | The vacuum permeability, which relates magnetic induction to magnetic field strength.
`ΞΌ_0 β‰ˆ 1.25663706212 x 10^-6 N A^-2` | Used in calculations related to electromagnetism and magnetic fields. | +//!| VACUUM_PERMITTIVITY | The vacuum permittivity, which relates electric displacement to electric field strength.
`Ξ΅_0 β‰ˆ 8.8541878128 x 10^-12 F m^-1` | Used in calculations related to electromagnetism and electric fields. | +//! +//! The following table lists the dictionaries available in the Common library. //! //!| Words | Description | //!| --- | --- | @@ -171,7 +182,9 @@ impl Common { .as_array() .expect("Words data is not an array") .iter() - .map(|word_value| word_value.as_str().unwrap().to_string()) + .map(|word_value| { + word_value.as_str().unwrap().to_string() + }) .collect::>() }) .unwrap_or_default(); // Add this line @@ -180,11 +193,20 @@ impl Common { words: HashSet::from_iter(words_data), } } - /// Parses a string of JSON data and returns a new instance of the - /// `Common` structure. + /// Parses a string of JSON data and returns a new instance of the `Common` structure. pub fn parse(input: &str) -> Result { - match serde_json::from_str(input) { - Ok(common) => Ok(common), + match serde_json::from_str::(input) { + Ok(common) => { + if common.fields.is_null() + || common.fields.is_object() + && common.fields.as_object().unwrap().is_empty() + { + // If the `fields` object is null or empty, return the default `Common` instance + Ok(Common::default()) + } else { + Ok(common) + } + } Err(e) => { // Handle the JSON parsing error match e.classify() { diff --git a/src/macros.rs b/src/macros.rs index ed7ff54..ecd2ff0 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -81,6 +81,18 @@ macro_rules! cmn_join { }}; } +/// This macro creates a new map of the given key-value pairs. +#[macro_export] +macro_rules! cmn_map { + ($($key:expr => $value:expr),*) => {{ + let mut map = ::std::collections::HashMap::new(); + $( + map.insert($key, $value); + )* + map + }}; +} + /// This macro finds the maximum value of the given values. #[macro_export] macro_rules! cmn_max { @@ -135,6 +147,14 @@ macro_rules! cmn_split { }}; } +/// This macro converts the given string to a number. +#[macro_export] +macro_rules! cmn_to_num { + ($s:expr) => { + $s.parse::().unwrap_or(0.0) + }; +} + /// This macro creates a new vector with the given elements. #[macro_export] macro_rules! cmn_vec { diff --git a/src/words.rs b/src/words.rs index b12d3fb..b197e7d 100644 --- a/src/words.rs +++ b/src/words.rs @@ -41,7 +41,8 @@ impl Words { /// This method provides access to the words as a sorted vector. It is useful for operations /// that may require ordered data, like displaying words in a user interface. pub fn words_list(&self) -> Vec { - let mut words_vec: Vec = self.words.iter().cloned().collect(); + let mut words_vec: Vec = + self.words.iter().cloned().collect(); words_vec.sort(); words_vec } @@ -82,16 +83,14 @@ impl Default for Words { /// This method is automatically called when creating a new instance of `Words` /// using `Words::default()`. fn default() -> Self { - let mut sorted_words: Vec = WORD_LIST - .iter() - .map(|&word| word.to_owned()) - .collect(); - + let mut sorted_words: Vec<&str> = WORD_LIST.to_vec(); sorted_words.sort_unstable(); - sorted_words.dedup(); Words { - words: sorted_words.into_iter().collect(), + words: sorted_words + .into_iter() + .map(|s| s.to_owned()) + .collect(), } } } @@ -102,243 +101,243 @@ pub const WORD_LIST: &[&str] = &[ "abrupt", "absent", "absorb", "absurd", "abuse", "accent", "accept", "access", "accord", "accuse", "ace", "ache", "aching", "acid", "acidic", "acorn", "acre", "across", "act", "action", - "active", "actor", "actual", "acute", "adapt", "add", "added", - "addict", "adept", "adhere", "adjust", "admire", "admit", "adam", - "advert", "aerial", "afar", "affair", "affect", "afford", "afield", - "afghan", "alaska", "alice", "allah", "amazon", "andrew", "anglo", - "afloat", "afraid", "afresh", "after", "again", "age", "agency", - "agenda", "agent", "aghast", "agile", "ago", "agony", "agree", - "agreed", "ahead", "aid", "aide", "aim", "air", "airman", "airy", - "akin", "alarm", "albeit", "album", "alert", "alibi", "alien", - "alight", "align", "alike", "alive", "alkali", "all", "alley", - "allied", "allow", "alloy", "ally", "almond", "almost", "aloft", - "alone", "along", "aloof", "aloud", "alpha", "alpine", "also", - "altar", "alter", "always", "amaze", "amber", "ambush", "amen", - "amend", "amid", "amidst", "amiss", "among", "amount", "ample", - "amuse", "anchor", "and", "anew", "angel", "anger", "angle", - "angola", "antony", "adobe", "adopt", "adrift", "adult", "adverb", - "angry", "animal", "ankle", "annoy", "annual", "answer", "anthem", - "anti", "any", "anyhow", "anyway", "apart", "apathy", "apex", - "apiece", "appeal", "appear", "apple", "apply", "apron", "arcade", - "april", "arab", "arctic", "athens", "austin", "bach", "baltic", - "arcane", "arch", "ardent", "are", "area", "argue", "arid", + "active", "actor", "actual", "acute", "adam", "adapt", "add", + "added", "addict", "adept", "adhere", "adjust", "admire", "admit", + "adobe", "adopt", "adrift", "adult", "adverb", "advert", "aerial", + "afar", "affair", "affect", "afford", "afghan", "afield", "afloat", + "afraid", "afresh", "after", "again", "age", "agency", "agenda", + "agent", "aghast", "agile", "ago", "agony", "agree", "agreed", + "ahead", "aid", "aide", "aim", "air", "airman", "airy", "akin", + "alarm", "alaska", "albeit", "album", "alert", "alibi", "alice", + "alien", "alight", "align", "alike", "alive", "alkali", "all", + "allah", "alley", "allied", "allow", "alloy", "ally", "almond", + "almost", "aloft", "alone", "along", "aloof", "aloud", "alpha", + "alpine", "also", "altar", "alter", "always", "amaze", "amazon", + "amber", "ambush", "amen", "amend", "amid", "amidst", "amiss", + "among", "amount", "ample", "amuse", "anchor", "and", "andrew", + "anew", "angel", "anger", "angle", "anglo", "angola", "angry", + "animal", "ankle", "annoy", "annual", "answer", "anthem", "anti", + "antony", "any", "anyhow", "anyway", "apart", "apathy", "apex", + "apiece", "appeal", "appear", "apple", "apply", "april", "apron", + "arab", "arcade", "arcane", "arch", "arctic", "ardent", "are", + "area", "argue", "arid", "arise", "arm", "armful", "armpit", "army", "aroma", "around", "arouse", "array", "arrest", "arrive", "arrow", "arson", "art", "artery", "artful", "artist", "ascent", "ashen", "ashore", "aside", "ask", "asleep", "aspect", "assay", "assent", "assert", "assess", "asset", "assign", "assist", - "assume", "assure", "asthma", "astute", "asylum", "ate", "atlas", - "atom", "atomic", "attach", "attack", "attain", "attend", "attic", - "auburn", "audio", "audit", "august", "aunt", "auntie", "aura", - "author", "auto", "autumn", "avail", "avenge", "avenue", "avert", - "avid", "avoid", "await", "awake", "awaken", "award", "aware", - "awash", "away", "awful", "awhile", "axes", "axiom", "axis", - "axle", "aye", "babe", "baby", "back", "backup", "bacon", "bad", - "badge", "badly", "bag", "baggy", "bail", "bait", "bake", "baker", - "bakery", "bald", "ball", "ballad", "ballet", "ballot", "bamboo", - "ban", "banal", "banana", "band", "bang", "bank", "bar", "barber", - "bare", "barely", "barge", "bark", "barley", "barn", "baron", - "barrel", "barren", "basalt", "base", "basic", "basil", "basin", - "basis", "basket", "bass", "bat", "batch", "bath", "baton", - "basque", "berlin", "bible", "arise", "arm", "armful", "armpit", - "battle", "bay", "beach", "beacon", "beak", "beam", "bean", "bear", - "beard", "beast", "beat", "beauty", "become", "bed", "beech", - "beef", "beefy", "beep", "beer", "beet", "beetle", "before", - "beggar", "begin", "behalf", "behave", "behind", "beige", "being", - "belief", "bell", "belly", "belong", "below", "belt", "bench", - "bend", "benign", "bent", "berry", "berth", "beset", "beside", - "best", "bestow", "bet", "beta", "betray", "better", "beware", - "beyond", "bias", "biceps", "bicker", "bid", "big", "bigger", - "bike", "bile", "bill", "binary", "bind", "biopsy", "birch", - "bird", "birdie", "birth", "bishop", "bit", "bitch", "bite", - "bitter", "black", "blade", "blame", "bland", "blast", "blaze", - "bleak", "blend", "bless", "blew", "blind", "blink", "blip", - "bliss", "blitz", "block", "blond", "blood", "bloody", "bloom", - "blot", "blouse", "blow", "blue", "bluff", "blunt", "blur", - "blush", "boar", "board", "boast", "boat", "bodily", "body", - "bogus", "boil", "bold", "bolt", "bomb", "bond", "bombay", "bonn", - "boost", "boot", "booth", "booze", "border", "bore", "borrow", - "bosom", "boss", "both", "bother", "bottle", "bottom", "bought", - "boston", "brazil", "briton", "buddha", "burma", "caesar", "cairo", - "bounce", "bound", "bounty", "bout", "bovine", "bow", "bowel", - "bowl", "box", "boy", "boyish", "brace", "brain", "brainy", - "brake", "bran", "branch", "brand", "brandy", "brass", "brave", - "bravo", "breach", "bread", "break", "breast", "breath", "bred", - "breed", "breeze", "brew", "brick", "bride", "bridge", "brief", - "bright", "brim", "brine", "bring", "brink", "brisk", "broad", + "assume", "assure", "asthma", "astute", "asylum", "ate", "athens", + "atlas", "atom", "atomic", "attach", "attack", "attain", "attend", + "attic", "auburn", "audio", "audit", "august", "aunt", "auntie", + "aura", "austin", "author", "auto", "autumn", "avail", "avenge", + "avenue", "avert", "avid", "avoid", "await", "awake", "awaken", + "award", "aware", "awash", "away", "awful", "awhile", "axes", + "axiom", "axis", "axle", "aye", "babe", "baby", "bach", "back", + "backup", "bacon", "bad", "badge", "badly", "bag", "baggy", "bail", + "bait", "bake", "baker", "bakery", "bald", "ball", "ballad", + "ballet", "ballot", "baltic", "bamboo", "ban", "banal", "banana", + "band", "bang", "bank", "bar", "barber", "bare", "barely", "barge", + "bark", "barley", "barn", "baron", "barrel", "barren", "basalt", + "base", "basic", "basil", "basin", "basis", "basket", "basque", + "bass", "bat", "batch", "bath", "baton", "battle", "bay", "beach", + "beacon", "beak", "beam", "bean", "bear", "beard", "beast", "beat", + "beauty", "become", "bed", "beech", "beef", "beefy", "beep", + "beer", "beet", "beetle", "before", "beggar", "begin", "behalf", + "behave", "behind", "beige", "being", "belief", "bell", "belly", + "belong", "below", "belt", "bench", "bend", "benign", "bent", + "berlin", "berry", "berth", "beset", "beside", "best", "bestow", + "bet", "beta", "betray", "better", "beware", "beyond", "bias", + "bible", "biceps", "bicker", "bid", "big", "bigger", "bike", + "bile", "bill", "binary", "bind", "biopsy", "birch", "bird", + "birdie", "birth", "bishop", "bit", "bitch", "bite", "bitter", + "black", "blade", "blame", "bland", "blast", "blaze", "bleak", + "blend", "bless", "blew", "blind", "blink", "blip", "bliss", + "blitz", "block", "blond", "blood", "bloody", "bloom", "blot", + "blouse", "blow", "blue", "bluff", "blunt", "blur", "blush", + "boar", "board", "boast", "boat", "bodily", "body", "bogus", + "boil", "bold", "bolt", "bomb", "bombay", "bond", "bone", "bonn", + "bonnet", "bonus", "bony", "book", "boom", "boost", "boot", + "booth", "booze", "border", "bore", "borrow", "bosom", "boss", + "boston", "both", "bother", "bottle", "bottom", "bought", "bounce", + "bound", "bounty", "bout", "bovine", "bow", "bowel", "bowl", "box", + "boy", "boyish", "brace", "brain", "brainy", "brake", "bran", + "branch", "brand", "brandy", "brass", "brave", "bravo", "brazil", + "breach", "bread", "break", "breast", "breath", "bred", "breed", + "breeze", "brew", "brick", "bride", "bridge", "brief", "bright", + "brim", "brine", "bring", "brink", "brisk", "briton", "broad", "broke", "broken", "bronze", "brook", "broom", "brown", "bruise", "brush", "brutal", "brute", "bubble", "buck", "bucket", "buckle", - "budget", "buffet", "buggy", "build", "bulb", "bulge", "bulk", - "bulky", "bull", "bullet", "bully", "bump", "bumpy", "bunch", - "bundle", "bunk", "bunny", "burden", "bureau", "burial", "buried", - "burly", "burn", "burnt", "burrow", "burst", "bury", "bus", "bush", - "bust", "bustle", "busy", "but", "butler", "butt", "butter", - "button", "buy", "buyer", "buzz", "bye", "byte", "cab", "cabin", - "cable", "cache", "cactus", "cage", "cake", "calf", "call", - "caller", "calm", "calmly", "came", "camel", "camera", "camp", - "campus", "can", "canal", "canary", "cancel", "cancer", "candid", - "canada", "bone", "bonnet", "bonus", "bony", "book", "boom", - "candle", "candy", "cane", "canine", "canoe", "canopy", "canvas", - "canyon", "cap", "cape", "car", "carbon", "card", "care", "career", - "caress", "cargo", "carnal", "carp", "carpet", "carrot", "carry", - "cart", "carl", "carol", "celtic", "chile", "china", "christ", - "cask", "cast", "castle", "casual", "cat", "catch", "cater", - "cattle", "caught", "causal", "cause", "cave", "cease", "celery", - "cell", "cellar", "cement", "censor", "census", "cereal", "cervix", + "buddha", "budget", "buffet", "buggy", "build", "bulb", "bulge", + "bulk", "bulky", "bull", "bullet", "bully", "bump", "bumpy", + "bunch", "bundle", "bunk", "bunny", "burden", "bureau", "burial", + "buried", "burly", "burma", "burn", "burnt", "burrow", "burst", + "bury", "bus", "bush", "bust", "bustle", "busy", "but", "butler", + "butt", "butter", "button", "buy", "buyer", "buzz", "bye", "byte", + "cab", "cabin", "cable", "cache", "cactus", "caesar", "cage", + "cairo", "cake", "calf", "call", "caller", "calm", "calmly", + "came", "camel", "camera", "camp", "campus", "can", "canada", + "canal", "canary", "cancel", "cancer", "candid", "candle", "candy", + "cane", "canine", "canoe", "canopy", "canvas", "canyon", "cap", + "cape", "car", "carbon", "card", "care", "career", "caress", + "cargo", "carl", "carnal", "carol", "carp", "carpet", "carrot", + "carry", "cart", "cartel", "case", "cash", "cask", "cast", + "castle", "casual", "cat", "catch", "cater", "cattle", "caught", + "causal", "cause", "cave", "cease", "celery", "cell", "cellar", + "celtic", "cement", "censor", "census", "cereal", "cervix", "chain", "chair", "chalk", "chalky", "champ", "chance", "change", "chant", "chaos", "chap", "chapel", "charge", "charm", "chart", "chase", "chat", "cheap", "cheat", "check", "cheek", "cheeky", "cheer", "cheery", "cheese", "chef", "cherry", "chess", "chest", - "chew", "chic", "chick", "chief", "child", "chill", "chilly", - "chin", "chip", "choice", "choir", "choose", "chop", "choppy", - "chord", "chorus", "chose", "chosen", "chrome", "chunk", "chunky", - "church", "cider", "cigar", "cinema", "circa", "circle", "circus", - "cite", "city", "civic", "civil", "clad", "claim", "clammy", - "clan", "clap", "clash", "clasp", "class", "clause", "claw", - "clay", "clean", "clear", "clergy", "clerk", "clever", "click", - "client", "cliff", "climax", "climb", "clinch", "cling", "clinic", - "clip", "cloak", "clock", "clone", "close", "closer", "closet", - "cloth", "cloud", "cloudy", "clout", "clown", "club", "clue", - "clumsy", "clung", "clutch", "coach", "coal", "coarse", "coast", - "coat", "coax", "cobalt", "cobra", "coca", "cock", "cocoa", "code", - "coffee", "coffin", "cohort", "coil", "coin", "coke", "cold", - "collar", "colon", "colony", "colt", "column", "comb", "combat", - "come", "comedy", "comic", "commit", "common", "compel", "comply", - "concur", "cone", "confer", "consul", "convex", "convey", "convoy", - "congo", "cuba", "cyprus", "czech", "cartel", "case", "cash", - "cook", "cool", "cope", "copper", "copy", "coral", "cord", "core", - "cork", "corn", "corner", "corps", "corpse", "corpus", "cortex", - "cosmic", "cosmos", "cost", "costly", "cosy", "cotton", "couch", - "cough", "could", "count", "county", "coup", "couple", "coupon", - "course", "court", "cousin", "cove", "cover", "covert", "cow", - "coward", "cowboy", "crab", "crack", "cradle", "craft", "crafty", - "crag", "crane", "crap", "crash", "crate", "crater", "crawl", - "crazy", "creak", "cream", "creamy", "create", "credit", "creed", - "creek", "creep", "creepy", "crept", "crest", "crew", "cried", - "crime", "crisis", "crisp", "critic", "croft", "crook", "crop", - "cross", "crow", "crowd", "crown", "crude", "cruel", "cruise", - "crunch", "crush", "crust", "crux", "cry", "crypt", "cube", - "cubic", "cuckoo", "cuff", "cult", "cup", "curb", "cure", "curfew", - "curl", "curry", "curse", "cursor", "curve", "custom", "cut", - "cute", "cycle", "cyclic", "cynic", "dad", "daddy", "dagger", - "daily", "dairy", "daisy", "dale", "damage", "damn", "damp", - "dampen", "dance", "danger", "dare", "dallas", "danish", "darwin", - "dark", "darken", "dash", "data", "date", "dawn", "day", "dead", - "david", "delhi", "derby", "diana", "dublin", "dutch", "east", - "deadly", "deaf", "deal", "dealer", "dean", "dear", "death", - "debate", "debit", "debris", "debt", "debtor", "decade", "decay", - "decent", "decide", "deck", "decor", "decree", "deduce", "deed", - "deep", "deeply", "deer", "defeat", "defect", "defend", "defer", - "define", "defy", "degree", "deity", "delay", "delete", "delta", - "demand", "demise", "demo", "demon", "demure", "denial", "denote", - "dense", "dental", "deny", "depart", "depend", "depict", "deploy", - "depot", "depth", "deputy", "derive", "desert", "design", "desire", - "desist", "desk", "detail", "detect", "deter", "detest", "detour", - "device", "devil", "devise", "devoid", "devote", "devour", "dial", - "diary", "dice", "dictum", "did", "die", "diesel", "diet", - "differ", "digest", "digit", "dine", "dinghy", "dinner", "diode", - "dire", "direct", "dirt", "dirty", "disc", "disco", "dish", "disk", - "dismal", "dispel", "ditch", "dive", "divert", "divide", "divine", - "dizzy", "docile", "dock", "doctor", "dog", "dogma", "dole", - "doll", "dollar", "dolly", "domain", "dome", "domino", "donate", - "done", "donkey", "donor", "doom", "door", "dorsal", "dose", - "double", "doubt", "dough", "dour", "dove", "down", "dozen", - "draft", "drag", "dragon", "drain", "drama", "drank", "draw", - "drawer", "dread", "dream", "dreary", "dress", "drew", "dried", - "drift", "drill", "drink", "drip", "drive", "driver", "drop", - "drove", "drown", "drug", "drum", "drunk", "dry", "dual", "duck", - "duct", "due", "duel", "duet", "duke", "dull", "duly", "dumb", - "dummy", "dump", "dune", "dung", "duress", "during", "dusk", - "dust", "dusty", "duty", "dwarf", "dwell", "dyer", "dying", + "chew", "chic", "chick", "chief", "child", "chile", "chill", + "chilly", "chin", "china", "chip", "choice", "choir", "choose", + "chop", "choppy", "chord", "chorus", "chose", "chosen", "christ", + "chrome", "chunk", "chunky", "church", "cider", "cigar", "cinema", + "circa", "circle", "circus", "cite", "city", "civic", "civil", + "clad", "claim", "clammy", "clan", "clap", "clash", "clasp", + "class", "clause", "claw", "clay", "clean", "clear", "clergy", + "clerk", "clever", "click", "client", "cliff", "climax", "climb", + "clinch", "cling", "clinic", "clip", "cloak", "clock", "clone", + "close", "closer", "closet", "cloth", "cloud", "cloudy", "clout", + "clown", "club", "clue", "clumsy", "clung", "clutch", "coach", + "coal", "coarse", "coast", "coat", "coax", "cobalt", "cobra", + "coca", "cock", "cocoa", "code", "coffee", "coffin", "cohort", + "coil", "coin", "coke", "cold", "collar", "colon", "colony", + "colt", "column", "comb", "combat", "come", "comedy", "comic", + "commit", "common", "compel", "comply", "concur", "cone", "confer", + "congo", "consul", "convex", "convey", "convoy", "cook", "cool", + "cope", "copper", "copy", "coral", "cord", "core", "cork", "corn", + "corner", "corps", "corpse", "corpus", "cortex", "cosmic", + "cosmos", "cost", "costly", "cosy", "cotton", "couch", "cough", + "could", "count", "county", "coup", "couple", "coupon", "course", + "court", "cousin", "cove", "cover", "covert", "cow", "coward", + "cowboy", "crab", "crack", "cradle", "craft", "crafty", "crag", + "crane", "crap", "crash", "crate", "crater", "crawl", "crazy", + "creak", "cream", "creamy", "create", "credit", "creed", "creek", + "creep", "creepy", "crept", "crest", "crew", "cried", "crime", + "crisis", "crisp", "critic", "croft", "crook", "crop", "cross", + "crow", "crowd", "crown", "crude", "cruel", "cruise", "crunch", + "crush", "crust", "crux", "cry", "crypt", "cuba", "cube", "cubic", + "cuckoo", "cuff", "cult", "cup", "curb", "cure", "curfew", "curl", + "curry", "curse", "cursor", "curve", "custom", "cut", "cute", + "cycle", "cyclic", "cynic", "cyprus", "czech", "dad", "daddy", + "dagger", "daily", "dairy", "daisy", "dale", "dallas", "damage", + "damn", "damp", "dampen", "dance", "danger", "danish", "dare", + "dark", "darken", "darwin", "dash", "data", "date", "david", + "dawn", "day", "dead", "deadly", "deaf", "deal", "dealer", "dean", + "dear", "death", "debate", "debit", "debris", "debt", "debtor", + "decade", "decay", "decent", "decide", "deck", "decor", "decree", + "deduce", "deed", "deep", "deeply", "deer", "defeat", "defect", + "defend", "defer", "define", "defy", "degree", "deity", "delay", + "delete", "delhi", "delta", "demand", "demise", "demo", "demon", + "demure", "denial", "denote", "dense", "dental", "deny", "depart", + "depend", "depict", "deploy", "depot", "depth", "deputy", "derby", + "derive", "desert", "design", "desire", "desist", "desk", "detail", + "detect", "deter", "detest", "detour", "device", "devil", "devise", + "devoid", "devote", "devour", "dial", "diana", "diary", "dice", + "dictum", "did", "die", "diesel", "diet", "differ", "digest", + "digit", "dine", "dinghy", "dinner", "diode", "dire", "direct", + "dirt", "dirty", "disc", "disco", "dish", "disk", "dismal", + "dispel", "ditch", "dive", "divert", "divide", "divine", "dizzy", + "docile", "dock", "doctor", "dog", "dogma", "dole", "doll", + "dollar", "dolly", "domain", "dome", "domino", "donate", "done", + "donkey", "donor", "doom", "door", "dorsal", "dose", "double", + "doubt", "dough", "dour", "dove", "down", "dozen", "draft", "drag", + "dragon", "drain", "drama", "drank", "draw", "drawer", "dread", + "dream", "dreary", "dress", "drew", "dried", "drift", "drill", + "drink", "drip", "drive", "driver", "drop", "drove", "drown", + "drug", "drum", "drunk", "dry", "dual", "dublin", "duck", "duct", + "due", "duel", "duet", "duke", "dull", "duly", "dumb", "dummy", + "dump", "dune", "dung", "duress", "during", "dusk", "dust", + "dusty", "dutch", "duty", "dwarf", "dwell", "dyer", "dying", "dynamo", "each", "eager", "eagle", "ear", "earl", "early", "earn", - "earth", "ease", "easel", "easily", "easter", "easy", "eat", - "eaten", "eater", "echo", "eddy", "edge", "edible", "eden", - "edward", "eric", "essex", "europe", "eve", "exodus", "france", - "effect", "effort", "egg", "ego", "eight", "eighth", "eighty", - "either", "elbow", "elder", "eldest", "elect", "eleven", "elicit", - "elite", "else", "elude", "elves", "embark", "emblem", "embryo", - "emerge", "emit", "empire", "employ", "empty", "enable", "enamel", - "end", "endure", "enemy", "energy", "engage", "engine", "enjoy", - "enlist", "enough", "ensure", "entail", "enter", "entire", "entry", - "envoy", "envy", "enzyme", "epic", "epoch", "equal", "equate", - "equip", "equity", "era", "erase", "erect", "erode", "erotic", - "errant", "error", "escape", "escort", "essay", "estate", "esteem", - "ethic", "ethnic", "evade", "even", "event", "ever", "every", - "evict", "evil", "evoke", "evolve", "exact", "exam", "exceed", - "excel", "except", "excess", "excise", "excite", "excuse", - "exempt", "exert", "exile", "exist", "exit", "exotic", "expand", - "expect", "expert", "expire", "export", "expose", "extend", - "extra", "eye", "eyed", "fabric", "face", "facial", "fact", - "factor", "fade", "fail", "faint", "fair", "fairly", "fairy", - "faith", "fake", "falcon", "fall", "false", "falter", "fame", - "family", "famine", "famous", "fan", "fancy", "far", "farce", - "fare", "farm", "farmer", "fast", "fasten", "faster", "fat", - "fatal", "fate", "father", "fatty", "fault", "faulty", "fauna", - "fear", "feast", "feat", "fed", "fee", "feeble", "feed", "feel", - "feet", "fell", "fellow", "felt", "female", "fence", "fend", - "ferry", "fetal", "fetch", "feudal", "fever", "few", "fewer", - "fiance", "fiasco", "fiddle", "field", "fiend", "fierce", "fiery", - "fifth", "fifty", "fig", "fight", "figure", "file", "fill", - "filled", "filler", "film", "filter", "filth", "filthy", "final", - "finale", "find", "fine", "finger", "finish", "finite", "fire", - "firm", "firmly", "first", "fiscal", "fish", "fisher", "fist", - "fit", "fitful", "five", "fix", "flag", "flair", "flak", "flame", - "flank", "flap", "flare", "flash", "flask", "flat", "flaw", "fled", - "flee", "fleece", "fleet", "flesh", "fleshy", "flew", "flick", - "flight", "flimsy", "flint", "flirt", "float", "flock", "flood", - "floor", "floppy", "flora", "floral", "flour", "flow", "flower", - "fluent", "fluffy", "fluid", "flung", "flurry", "flush", "flute", - "flux", "fly", "flyer", "foal", "foam", "focal", "focus", "fog", - "foil", "fold", "folk", "follow", "folly", "fond", "fondly", - "font", "food", "fool", "foot", "for", "forbid", "force", "ford", - "forest", "forge", "forget", "fork", "form", "formal", "format", - "former", "fort", "forth", "forty", "forum", "fossil", "foster", - "foul", "found", "four", "fourth", "fox", "foyer", "frail", - "frame", "franc", "frank", "fraud", "free", "freed", "freely", - "freer", "freeze", "frenzy", "fresh", "friar", "fridge", "fried", - "french", "friday", "edict", "edit", "editor", "eerie", "eerily", - "friend", "fright", "fringe", "frock", "frog", "from", "front", - "frost", "frosty", "frown", "frozen", "frugal", "fruit", "fudge", - "fuel", "fulfil", "full", "fully", "fun", "fund", "funny", "fur", - "furry", "fury", "fuse", "fusion", "fuss", "fussy", "futile", - "future", "fuzzy", "gadget", "gag", "gain", "gala", "galaxy", - "gale", "gall", "galley", "gallon", "gallop", "gamble", "game", - "gamma", "gang", "gandhi", "gaul", "gemini", "geneva", "george", - "garden", "garlic", "gas", "gasp", "gate", "gather", "gauge", - "gaunt", "gave", "gay", "gaze", "gear", "geese", "gender", "gene", - "genial", "genius", "genre", "gentle", "gently", "gentry", "genus", - "german", "gloria", "god", "gothic", "greece", "gap", "garage", - "get", "ghetto", "ghost", "giant", "gift", "giggle", "gill", - "gilt", "ginger", "girl", "give", "given", "glad", "glade", - "glance", "gland", "glare", "glass", "glassy", "gleam", "glee", - "glide", "global", "globe", "gloom", "gloomy", "glory", "gloss", - "glossy", "glove", "glow", "glue", "goal", "goat", "gold", - "golden", "golf", "gone", "gong", "good", "goose", "gorge", "gory", - "gosh", "gospel", "gossip", "got", "govern", "gown", "grab", + "earth", "ease", "easel", "easily", "east", "easter", "easy", + "eat", "eaten", "eater", "echo", "eddy", "eden", "edge", "edible", + "edict", "edit", "editor", "edward", "eerie", "eerily", "effect", + "effort", "egg", "ego", "eight", "eighth", "eighty", "either", + "elbow", "elder", "eldest", "elect", "eleven", "elicit", "elite", + "else", "elude", "elves", "embark", "emblem", "embryo", "emerge", + "emit", "empire", "employ", "empty", "enable", "enamel", "end", + "endure", "enemy", "energy", "engage", "engine", "enjoy", "enlist", + "enough", "ensure", "entail", "enter", "entire", "entry", "envoy", + "envy", "enzyme", "epic", "epoch", "equal", "equate", "equip", + "equity", "era", "erase", "erect", "eric", "erode", "erotic", + "errant", "error", "escape", "escort", "essay", "essex", "estate", + "esteem", "ethic", "ethnic", "europe", "evade", "eve", "even", + "event", "ever", "every", "evict", "evil", "evoke", "evolve", + "exact", "exam", "exceed", "excel", "except", "excess", "excise", + "excite", "excuse", "exempt", "exert", "exile", "exist", "exit", + "exodus", "exotic", "expand", "expect", "expert", "expire", + "export", "expose", "extend", "extra", "eye", "eyed", "fabric", + "face", "facial", "fact", "factor", "fade", "fail", "faint", + "fair", "fairly", "fairy", "faith", "fake", "falcon", "fall", + "false", "falter", "fame", "family", "famine", "famous", "fan", + "fancy", "far", "farce", "fare", "farm", "farmer", "fast", + "fasten", "faster", "fat", "fatal", "fate", "father", "fatty", + "fault", "faulty", "fauna", "fear", "feast", "feat", "fed", "fee", + "feeble", "feed", "feel", "feet", "fell", "fellow", "felt", + "female", "fence", "fend", "ferry", "fetal", "fetch", "feudal", + "fever", "few", "fewer", "fiance", "fiasco", "fiddle", "field", + "fiend", "fierce", "fiery", "fifth", "fifty", "fig", "fight", + "figure", "file", "fill", "filled", "filler", "film", "filter", + "filth", "filthy", "final", "finale", "find", "fine", "finger", + "finish", "finite", "fire", "firm", "firmly", "first", "fiscal", + "fish", "fisher", "fist", "fit", "fitful", "five", "fix", "flag", + "flair", "flak", "flame", "flank", "flap", "flare", "flash", + "flask", "flat", "flaw", "fled", "flee", "fleece", "fleet", + "flesh", "fleshy", "flew", "flick", "flight", "flimsy", "flint", + "flirt", "float", "flock", "flood", "floor", "floppy", "flora", + "floral", "flour", "flow", "flower", "fluent", "fluffy", "fluid", + "flung", "flurry", "flush", "flute", "flux", "fly", "flyer", + "foal", "foam", "focal", "focus", "fog", "foil", "fold", "folk", + "follow", "folly", "fond", "fondly", "font", "food", "fool", + "foot", "for", "forbid", "force", "ford", "forest", "forge", + "forget", "fork", "form", "formal", "format", "former", "fort", + "forth", "forty", "forum", "fossil", "foster", "foul", "found", + "four", "fourth", "fox", "foyer", "frail", "frame", "franc", + "france", "frank", "fraud", "free", "freed", "freely", "freer", + "freeze", "french", "frenzy", "fresh", "friar", "friday", "fridge", + "fried", "friend", "fright", "fringe", "frock", "frog", "from", + "front", "frost", "frosty", "frown", "frozen", "frugal", "fruit", + "fudge", "fuel", "fulfil", "full", "fully", "fun", "fund", "funny", + "fur", "furry", "fury", "fuse", "fusion", "fuss", "fussy", + "futile", "future", "fuzzy", "gadget", "gag", "gain", "gala", + "galaxy", "gale", "gall", "galley", "gallon", "gallop", "gamble", + "game", "gamma", "gandhi", "gang", "gap", "garage", "garden", + "garlic", "gas", "gasp", "gate", "gather", "gauge", "gaul", + "gaunt", "gave", "gay", "gaze", "gear", "geese", "gemini", + "gender", "gene", "geneva", "genial", "genius", "genre", "gentle", + "gently", "gentry", "genus", "george", "german", "get", "ghetto", + "ghost", "giant", "gift", "giggle", "gill", "gilt", "ginger", + "girl", "give", "given", "glad", "glade", "glance", "gland", + "glare", "glass", "glassy", "gleam", "glee", "glide", "global", + "globe", "gloom", "gloomy", "gloria", "glory", "gloss", "glossy", + "glove", "glow", "glue", "goal", "goat", "god", "gold", "golden", + "golf", "gone", "gong", "good", "goose", "gorge", "gory", "gosh", + "gospel", "gossip", "got", "gothic", "govern", "gown", "grab", "grace", "grade", "grain", "grand", "grant", "grape", "graph", "grasp", "grass", "grassy", "grate", "grave", "gravel", "gravy", - "gray", "grease", "greasy", "great", "greed", "greedy", "green", - "greet", "grew", "grey", "grid", "grief", "grill", "grim", "grin", - "grind", "greek", "hague", "haiti", "hanoi", "harry", "havana", + "gray", "grease", "greasy", "great", "greece", "greed", "greedy", + "greek", "green", "greet", "grew", "grey", "grid", "grief", + "grill", "grim", "grin", "grind", "grip", "grit", "gritty", "groan", "groin", "groom", "groove", "gross", "ground", "group", "grove", "grow", "grown", "growth", "grudge", "grunt", "guard", "guess", "guest", "guide", "guild", "guilt", "guilty", "guise", "guitar", "gulf", "gully", "gun", "gunman", "guru", "gut", "guy", - "gypsy", "habit", "hack", "had", "hail", "hair", "hairy", "hale", - "half", "hall", "halt", "hamlet", "hammer", "hand", "handle", - "handy", "hang", "hangar", "happen", "happy", "harass", "hard", - "harder", "hardly", "hare", "harem", "harm", "harp", "harsh", - "has", "hash", "hassle", "haste", "hasten", "hasty", "hat", - "hatch", "hate", "haul", "haunt", "have", "haven", "havoc", "hawk", - "hawaii", "hebrew", "henry", "hermes", "grip", "grit", "gritty", - "hazard", "haze", "hazel", "hazy", "head", "heal", "health", - "heap", "hear", "heard", "heart", "hearth", "hearty", "heat", - "heater", "heaven", "heavy", "heck", "hectic", "hedge", "heel", - "hefty", "height", "heir", "held", "helium", "helix", "hell", - "hello", "helm", "helmet", "help", "hemp", "hence", "her", - "herald", "herb", "herd", "here", "hereby", "hernia", "hero", - "heroic", "heroin", "hey", "heyday", "hick", "hidden", "hide", - "high", "higher", "highly", "hill", "him", "hind", "hint", "hippy", - "hire", "his", "hiss", "hit", "hive", "hindu", "hitler", "idaho", + "gypsy", "habit", "hack", "had", "hague", "hail", "hair", "hairy", + "haiti", "hale", "half", "hall", "halt", "hamlet", "hammer", + "hand", "handle", "handy", "hang", "hangar", "hanoi", "happen", + "happy", "harass", "hard", "harder", "hardly", "hare", "harem", + "harm", "harp", "harry", "harsh", "has", "hash", "hassle", "haste", + "hasten", "hasty", "hat", "hatch", "hate", "haul", "haunt", + "havana", "have", "haven", "havoc", "hawaii", "hawk", "hazard", + "haze", "hazel", "hazy", "head", "heal", "health", "heap", "hear", + "heard", "heart", "hearth", "hearty", "heat", "heater", "heaven", + "heavy", "hebrew", "heck", "hectic", "hedge", "heel", "hefty", + "height", "heir", "held", "helium", "helix", "hell", "hello", + "helm", "helmet", "help", "hemp", "hence", "henry", "her", + "herald", "herb", "herd", "here", "hereby", "hermes", "hernia", + "hero", "heroic", "heroin", "hey", "heyday", "hick", "hidden", + "hide", "high", "higher", "highly", "hill", "him", "hind", "hindu", + "hint", "hippy", "hire", "his", "hiss", "hit", "hitler", "hive", "hoard", "hoarse", "hobby", "hockey", "hold", "holder", "hole", "hollow", "holly", "holy", "home", "honest", "honey", "hood", "hook", "hope", "horn", "horny", "horrid", "horror", "horse", @@ -346,151 +345,151 @@ pub const WORD_LIST: &[&str] = &[ "how", "huge", "hull", "human", "humane", "humble", "humid", "hung", "hunger", "hungry", "hunt", "hurdle", "hurl", "hurry", "hurt", "hush", "hut", "hybrid", "hymn", "hyphen", "ice", "icing", - "icon", "idea", "ideal", "idiom", "idiot", "idle", "idly", "idol", - "ignite", "ignore", "ill", "image", "immune", "impact", "imply", - "import", "impose", "incest", "inch", "income", "incur", "indeed", - "inca", "india", "indian", "iowa", "iran", "iraq", "irish", - "index", "indoor", "induce", "inept", "inert", "infant", "infect", - "infer", "influx", "inform", "inject", "injure", "injury", - "inlaid", "inland", "inlet", "inmate", "inn", "innate", "inner", - "input", "insane", "insect", "insert", "inset", "inside", "insist", - "insult", "insure", "intact", "intake", "intend", "inter", "into", - "invade", "invent", "invest", "invite", "invoke", "inward", "iron", - "ironic", "irony", "island", "isle", "issue", "itch", "item", - "isaac", "isabel", "islam", "israel", "italy", "ivan", "jack", - "jacob", "james", "japan", "itself", "ivory", "jacket", "jade", - "jaguar", "jail", "jargon", "jaw", "jazz", "jeep", "java", - "jersey", "jesus", "jewish", "jim", "john", "jordan", "joseph", - "jock", "jockey", "join", "joint", "joke", "jolly", "jolt", "joy", - "joyful", "joyous", "judge", "juice", "juicy", "jumble", "jumbo", - "judas", "judy", "jelly", "jerky", "jest", "jet", "jewel", "job", - "july", "june", "kansas", "karl", "kenya", "koran", "korea", - "junk", "junta", "jury", "just", "karate", "keel", "keen", "keep", - "keeper", "kept", "kernel", "kettle", "key", "khaki", "kick", - "kid", "kidnap", "kidney", "kill", "killer", "kin", "kind", - "kindly", "king", "kiss", "kite", "kitten", "knack", "knee", - "knew", "knife", "knight", "knit", "knob", "knock", "knot", "know", - "known", "label", "lace", "lack", "lad", "ladder", "laden", "lady", - "kuwait", "laos", "latin", "leo", "jump", "jungle", "junior", - "lagoon", "laity", "lake", "lamb", "lame", "lamp", "lance", "land", - "lane", "lap", "lapse", "large", "larval", "laser", "last", - "latch", "late", "lately", "latent", "later", "latest", "latter", - "laugh", "launch", "lava", "lavish", "law", "lawful", "lawn", - "lawyer", "lay", "layer", "layman", "lazy", "lead", "leader", - "leaf", "leafy", "league", "leak", "leaky", "lean", "leap", - "learn", "lease", "leash", "least", "leave", "led", "ledge", - "left", "leg", "legacy", "legal", "legend", "legion", "lemon", - "lend", "length", "lens", "lent", "leper", "lesion", "less", - "lessen", "lesser", "lesson", "lest", "let", "lethal", "letter", - "level", "lever", "levy", "lewis", "liable", "liar", "libel", - "libya", "lima", "lisbon", "liz", "london", "louvre", "lucy", - "life", "lift", "light", "like", "likely", "limb", "lime", "limit", - "limp", "line", "linear", "linen", "linger", "link", "lion", "lip", - "liquid", "liquor", "list", "listen", "lit", "live", "lively", - "liver", "lizard", "load", "loaf", "loan", "lobby", "lobe", - "local", "locate", "lock", "locus", "lodge", "loft", "lofty", - "log", "logic", "logo", "lone", "lonely", "long", "longer", "look", - "loop", "loose", "loosen", "loot", "lord", "lorry", "lose", "loss", - "lost", "lot", "lotion", "lotus", "loud", "loudly", "lounge", - "lousy", "love", "lovely", "lover", "low", "lower", "lowest", - "loyal", "lucid", "luck", "lucky", "lull", "lump", "lumpy", - "lunacy", "lunar", "lunch", "lung", "lure", "lurid", "lush", - "lust", "lute", "luxury", "lying", "lymph", "lynch", "lyric", - "luther", "madame", "madrid", "lice", "lick", "lid", "lie", "lied", - "macho", "macro", "mad", "madam", "made", "mafia", "magic", - "magma", "magnet", "magnum", "maid", "maiden", "mail", "main", - "mainly", "major", "make", "maker", "male", "malice", "mall", - "malt", "mammal", "manage", "mane", "malta", "maria", "mars", - "mania", "manic", "manner", "manor", "mantle", "manual", "manure", - "many", "map", "maple", "marble", "march", "mare", "margin", - "marina", "mark", "market", "marry", "marsh", "martin", "martyr", - "mary", "maya", "mecca", "mexico", "miami", "mickey", "milan", - "mask", "mason", "mass", "mast", "master", "match", "mate", - "matrix", "matter", "mature", "maxim", "may", "maybe", "mayor", - "maze", "mead", "meadow", "meal", "mean", "meant", "meat", "medal", - "media", "median", "medic", "medium", "meet", "mellow", "melody", - "melon", "melt", "member", "memo", "memory", "menace", "mend", - "mental", "mentor", "menu", "mercy", "mere", "merely", "merge", - "merger", "merit", "merry", "mesh", "mess", "messy", "met", - "metal", "meter", "method", "methyl", "metric", "metro", "mid", - "midday", "middle", "midst", "midway", "might", "mighty", "mild", - "mildew", "mile", "milk", "milky", "mill", "mimic", "mince", - "mind", "mine", "mini", "mink", "minor", "mint", "minus", "minute", - "mirror", "mirth", "misery", "miss", "mist", "misty", "mite", - "mix", "moan", "moat", "mobile", "mock", "mode", "model", "modem", - "modern", "modest", "modify", "module", "moist", "molar", "mole", - "molten", "moment", "monaco", "monday", "moscow", "moses", - "monies", "monk", "monkey", "month", "mood", "moody", "moon", - "moor", "moral", "morale", "morbid", "more", "morgue", "mortal", - "mortar", "mosaic", "mosque", "moss", "most", "mostly", "moth", - "moslem", "mrs", "munich", "muslim", "naples", "nazi", "money", - "mother", "motion", "motive", "motor", "mould", "mount", "mourn", - "mouse", "mouth", "move", "movie", "much", "muck", "mucus", "mud", - "muddle", "muddy", "mule", "mummy", "murder", "murky", "murmur", - "muscle", "museum", "music", "mussel", "must", "mutant", "mute", - "mutiny", "mutter", "mutton", "mutual", "muzzle", "myopic", - "myriad", "myself", "mystic", "myth", "nadir", "nail", "naked", - "name", "namely", "nape", "napkin", "narrow", "nasal", "nasty", - "nation", "native", "nature", "nausea", "naval", "nave", "navy", + "icon", "idaho", "idea", "ideal", "idiom", "idiot", "idle", "idly", + "idol", "ignite", "ignore", "ill", "image", "immune", "impact", + "imply", "import", "impose", "inca", "incest", "inch", "income", + "incur", "indeed", "index", "india", "indian", "indoor", "induce", + "inept", "inert", "infant", "infect", "infer", "influx", "inform", + "inject", "injure", "injury", "inlaid", "inland", "inlet", + "inmate", "inn", "innate", "inner", "input", "insane", "insect", + "insert", "inset", "inside", "insist", "insult", "insure", + "intact", "intake", "intend", "inter", "into", "invade", "invent", + "invest", "invite", "invoke", "inward", "iowa", "iran", "iraq", + "irish", "iron", "ironic", "irony", "isaac", "isabel", "islam", + "island", "isle", "israel", "issue", "italy", "itch", "item", + "itself", "ivan", "ivory", "jack", "jacket", "jacob", "jade", + "jaguar", "jail", "james", "japan", "jargon", "java", "jaw", + "jazz", "jeep", "jelly", "jerky", "jersey", "jest", "jesus", "jet", + "jewel", "jewish", "jim", "job", "jock", "jockey", "john", "join", + "joint", "joke", "jolly", "jolt", "jordan", "joseph", "joy", + "joyful", "joyous", "judas", "judge", "judy", "juice", "juicy", + "july", "jumble", "jumbo", "jump", "june", "jungle", "junior", + "junk", "junta", "jury", "just", "kansas", "karate", "karl", + "keel", "keen", "keep", "keeper", "kenya", "kept", "kernel", + "kettle", "key", "khaki", "kick", "kid", "kidnap", "kidney", + "kill", "killer", "kin", "kind", "kindly", "king", "kiss", "kite", + "kitten", "knack", "knee", "knew", "knife", "knight", "knit", + "knob", "knock", "knot", "know", "known", "koran", "korea", + "kuwait", "label", "lace", "lack", "lad", "ladder", "laden", + "lady", "lagoon", "laity", "lake", "lamb", "lame", "lamp", "lance", + "land", "lane", "laos", "lap", "lapse", "large", "larval", "laser", + "last", "latch", "late", "lately", "latent", "later", "latest", + "latin", "latter", "laugh", "launch", "lava", "lavish", "law", + "lawful", "lawn", "lawyer", "lay", "layer", "layman", "lazy", + "lead", "leader", "leaf", "leafy", "league", "leak", "leaky", + "lean", "leap", "learn", "lease", "leash", "least", "leave", "led", + "ledge", "left", "leg", "legacy", "legal", "legend", "legion", + "lemon", "lend", "length", "lens", "lent", "leo", "leper", + "lesion", "less", "lessen", "lesser", "lesson", "lest", "let", + "lethal", "letter", "level", "lever", "levy", "lewis", "liable", + "liar", "libel", "libya", "lice", "lick", "lid", "lie", "lied", + "life", "lift", "light", "like", "likely", "lima", "limb", "lime", + "limit", "limp", "line", "linear", "linen", "linger", "link", + "lion", "lip", "liquid", "liquor", "lisbon", "list", "listen", + "lit", "live", "lively", "liver", "liz", "lizard", "load", "loaf", + "loan", "lobby", "lobe", "local", "locate", "lock", "locus", + "lodge", "loft", "lofty", "log", "logic", "logo", "london", "lone", + "lonely", "long", "longer", "look", "loop", "loose", "loosen", + "loot", "lord", "lorry", "lose", "loss", "lost", "lot", "lotion", + "lotus", "loud", "loudly", "lounge", "lousy", "louvre", "love", + "lovely", "lover", "low", "lower", "lowest", "loyal", "lucid", + "luck", "lucky", "lucy", "lull", "lump", "lumpy", "lunacy", + "lunar", "lunch", "lung", "lure", "lurid", "lush", "lust", "lute", + "luther", "luxury", "lying", "lymph", "lynch", "lyric", "macho", + "macro", "mad", "madam", "madame", "made", "madrid", "mafia", + "magic", "magma", "magnet", "magnum", "maid", "maiden", "mail", + "main", "mainly", "major", "make", "maker", "male", "malice", + "mall", "malt", "malta", "mammal", "manage", "mane", "mania", + "manic", "manner", "manor", "mantle", "manual", "manure", "many", + "map", "maple", "marble", "march", "mare", "margin", "maria", + "marina", "mark", "market", "marry", "mars", "marsh", "martin", + "martyr", "mary", "mask", "mason", "mass", "mast", "master", + "match", "mate", "matrix", "matter", "mature", "maxim", "may", + "maya", "maybe", "mayor", "maze", "mead", "meadow", "meal", "mean", + "meant", "meat", "mecca", "medal", "media", "median", "medic", + "medium", "meet", "mellow", "melody", "melon", "melt", "member", + "memo", "memory", "menace", "mend", "mental", "mentor", "menu", + "mercy", "mere", "merely", "merge", "merger", "merit", "merry", + "mesh", "mess", "messy", "met", "metal", "meter", "method", + "methyl", "metric", "metro", "mexico", "miami", "mickey", "mid", + "midday", "middle", "midst", "midway", "might", "mighty", "milan", + "mild", "mildew", "mile", "milk", "milky", "mill", "mimic", + "mince", "mind", "mine", "mini", "mink", "minor", "mint", "minus", + "minute", "mirror", "mirth", "misery", "miss", "mist", "misty", + "mite", "mix", "moan", "moat", "mobile", "mock", "mode", "model", + "modem", "modern", "modest", "modify", "module", "moist", "molar", + "mole", "molten", "moment", "monaco", "monday", "money", "monies", + "monk", "monkey", "month", "mood", "moody", "moon", "moor", + "moral", "morale", "morbid", "more", "morgue", "mortal", "mortar", + "mosaic", "moscow", "moses", "moslem", "mosque", "moss", "most", + "mostly", "moth", "mother", "motion", "motive", "motor", "mould", + "mount", "mourn", "mouse", "mouth", "move", "movie", "mrs", "much", + "muck", "mucus", "mud", "muddle", "muddy", "mule", "mummy", + "munich", "murder", "murky", "murmur", "muscle", "museum", "music", + "muslim", "mussel", "must", "mutant", "mute", "mutiny", "mutter", + "mutton", "mutual", "muzzle", "myopic", "myriad", "myself", + "mystic", "myth", "nadir", "nail", "naked", "name", "namely", + "nape", "napkin", "naples", "narrow", "nasal", "nasty", "nation", + "native", "nature", "nausea", "naval", "nave", "navy", "nazi", "near", "nearer", "nearly", "neat", "neatly", "neck", "need", - "needle", "needy", "negate", "neon", "nephew", "nepal", "newark", - "nice", "nicely", "niche", "nickel", "niece", "night", "nimble", - "nile", "nobel", "north", "norway", "ohio", "oscar", "oslo", - "nine", "ninety", "ninth", "noble", "nobody", "node", "noise", - "noisy", "non", "none", "noon", "nor", "norm", "normal", "nose", - "nosy", "not", "note", "notice", "notify", "notion", "nought", - "noun", "novel", "novice", "now", "nozzle", "nude", "null", "numb", - "number", "nurse", "nylon", "nymph", "oak", "oasis", "oath", - "obese", "obey", "object", "oblige", "oboe", "obtain", "occult", - "occupy", "occur", "ocean", "octave", "odd", "off", "offend", - "offer", "office", "offset", "often", "oil", "oily", "okay", "old", - "older", "oldest", "olive", "omega", "omen", "omit", "once", "one", - "onion", "only", "onset", "onto", "onus", "onward", "opaque", - "open", "openly", "opera", "opium", "oppose", "optic", "option", - "oracle", "oral", "orange", "orbit", "orchid", "ordeal", "order", - "organ", "orgasm", "orient", "origin", "ornate", "orphan", "other", + "needle", "needy", "negate", "neon", "nepal", "nephew", "nerve", + "nest", "neural", "never", "newark", "newly", "next", "nice", + "nicely", "niche", "nickel", "niece", "night", "nile", "nimble", + "nine", "ninety", "ninth", "nobel", "noble", "nobody", "node", + "noise", "noisy", "non", "none", "noon", "nor", "norm", "normal", + "north", "norway", "nose", "nosy", "not", "note", "notice", + "notify", "notion", "nought", "noun", "novel", "novice", "now", + "nozzle", "nude", "null", "numb", "number", "nurse", "nylon", + "nymph", "oak", "oasis", "oath", "obese", "obey", "object", + "oblige", "oboe", "obtain", "occult", "occupy", "occur", "ocean", + "octave", "odd", "off", "offend", "offer", "office", "offset", + "often", "ohio", "oil", "oily", "okay", "old", "older", "oldest", + "olive", "omega", "omen", "omit", "once", "one", "onion", "only", + "onset", "onto", "onus", "onward", "opaque", "open", "openly", + "opera", "opium", "oppose", "optic", "option", "oracle", "oral", + "orange", "orbit", "orchid", "ordeal", "order", "organ", "orgasm", + "orient", "origin", "ornate", "orphan", "oscar", "oslo", "other", "otter", "ought", "ounce", "our", "out", "outer", "output", "outset", "oval", "oven", "over", "overt", "owe", "owing", "owl", - "own", "owner", "oxide", "oxygen", "oyster", "ozone", "pace", - "oxford", "nerve", "nest", "neural", "never", "newly", "next", - "pack", "packet", "pact", "paddle", "paddy", "pagan", "page", - "paid", "pain", "paint", "pair", "palace", "pale", "palm", "panel", - "panic", "panama", "paris", "pascal", "paul", "peking", "peru", - "parade", "parcel", "pardon", "parent", "parish", "park", "parody", - "parrot", "part", "partly", "party", "pass", "past", "paste", - "pastel", "pastor", "pastry", "pat", "patch", "patent", "path", - "patio", "patrol", "patron", "pause", "pave", "pawn", "pay", - "peace", "peach", "peak", "pear", "pearl", "pedal", "peel", "peer", - "pelvic", "pelvis", "pen", "penal", "pence", "pencil", "penis", - "penny", "people", "pepper", "per", "perch", "peril", "period", - "perish", "permit", "person", "pest", "petite", "petrol", "petty", - "peter", "philip", "poland", "polish", "papa", "papal", "paper", - "phase", "phone", "photo", "phrase", "piano", "pick", "picket", - "picnic", "pie", "piece", "pier", "pierce", "piety", "pig", - "pigeon", "piggy", "pike", "pile", "pill", "pillar", "pillow", - "pilot", "pin", "pinch", "pine", "pink", "pint", "pious", "pipe", - "pirate", "piss", "pistol", "piston", "pit", "pitch", "pity", - "pivot", "pixel", "pizza", "place", "placid", "plague", "plain", - "plan", "plane", "planet", "plank", "plant", "plasma", "plate", - "play", "player", "plea", "plead", "please", "pledge", "plenty", - "plenum", "plight", "plot", "ploy", "plug", "plum", "plump", - "plunge", "plural", "plus", "plush", "pocket", "poem", "poet", - "poetic", "poetry", "point", "poison", "polar", "pole", "police", - "policy", "polite", "poll", "pollen", "polo", "pond", "ponder", - "pony", "pool", "poor", "poorly", "pop", "pope", "poppy", "pore", - "pork", "port", "portal", "pose", "posh", "post", "postal", "pot", - "potato", "potent", "pouch", "pound", "pour", "powder", "power", - "prague", "quebec", "rex", "rhine", "ritz", "robert", "roman", - "praise", "pray", "prayer", "preach", "prefer", "prefix", "press", - "primal", "prime", "prince", "print", "prior", "prism", "prison", - "privy", "prize", "probe", "profit", "prompt", "prone", "proof", - "propel", "proper", "prose", "proton", "proud", "prove", "proven", - "proxy", "prune", "psalm", "pseudo", "psyche", "pub", "public", - "puff", "pull", "pulp", "pulpit", "pulsar", "pulse", "pump", - "punch", "punish", "punk", "pupil", "puppet", "puppy", "pure", - "purely", "purge", "purify", "purple", "purse", "pursue", "push", - "pushy", "pussy", "put", "putt", "puzzle", "quaint", "quake", - "quarry", "quartz", "quay", "queen", "queer", "query", "quest", + "own", "owner", "oxford", "oxide", "oxygen", "oyster", "ozone", + "pace", "pack", "packet", "pact", "paddle", "paddy", "pagan", + "page", "paid", "pain", "paint", "pair", "palace", "pale", "palm", + "panama", "panel", "panic", "papa", "papal", "paper", "parade", + "parcel", "pardon", "parent", "paris", "parish", "park", "parody", + "parrot", "part", "partly", "party", "pascal", "pass", "past", + "paste", "pastel", "pastor", "pastry", "pat", "patch", "patent", + "path", "patio", "patrol", "patron", "paul", "pause", "pave", + "pawn", "pay", "peace", "peach", "peak", "pear", "pearl", "pedal", + "peel", "peer", "peking", "pelvic", "pelvis", "pen", "penal", + "pence", "pencil", "penis", "penny", "people", "pepper", "per", + "perch", "peril", "period", "perish", "permit", "person", "peru", + "pest", "peter", "petite", "petrol", "petty", "phase", "philip", + "phone", "photo", "phrase", "piano", "pick", "picket", "picnic", + "pie", "piece", "pier", "pierce", "piety", "pig", "pigeon", + "piggy", "pike", "pile", "pill", "pillar", "pillow", "pilot", + "pin", "pinch", "pine", "pink", "pint", "pious", "pipe", "pirate", + "piss", "pistol", "piston", "pit", "pitch", "pity", "pivot", + "pixel", "pizza", "place", "placid", "plague", "plain", "plan", + "plane", "planet", "plank", "plant", "plasma", "plate", "play", + "player", "plea", "plead", "please", "pledge", "plenty", "plenum", + "plight", "plot", "ploy", "plug", "plum", "plump", "plunge", + "plural", "plus", "plush", "pocket", "poem", "poet", "poetic", + "poetry", "point", "poison", "poland", "polar", "pole", "police", + "policy", "polish", "polite", "poll", "pollen", "polo", "pond", + "ponder", "pony", "pool", "poor", "poorly", "pop", "pope", "poppy", + "pore", "pork", "port", "portal", "pose", "posh", "post", "postal", + "pot", "potato", "potent", "pouch", "pound", "pour", "powder", + "power", "prague", "praise", "pray", "prayer", "preach", "prefer", + "prefix", "press", "pretty", "price", "pride", "priest", "primal", + "prime", "prince", "print", "prior", "prism", "prison", "privy", + "prize", "probe", "profit", "prompt", "prone", "proof", "propel", + "proper", "prose", "proton", "proud", "prove", "proven", "proxy", + "prune", "psalm", "pseudo", "psyche", "pub", "public", "puff", + "pull", "pulp", "pulpit", "pulsar", "pulse", "pump", "punch", + "punish", "punk", "pupil", "puppet", "puppy", "pure", "purely", + "purge", "purify", "purple", "purse", "pursue", "push", "pushy", + "pussy", "put", "putt", "puzzle", "quaint", "quake", "quarry", + "quartz", "quay", "quebec", "queen", "queer", "query", "quest", "queue", "quick", "quid", "quiet", "quilt", "quirk", "quit", "quite", "quiver", "quiz", "quota", "quote", "rabbit", "race", "racial", "racism", "rack", "racket", "radar", "radio", "radish", @@ -510,167 +509,167 @@ pub const WORD_LIST: &[&str] = &[ "repeat", "repent", "reply", "report", "rescue", "resent", "reside", "resign", "resin", "resist", "resort", "rest", "result", "resume", "retail", "retain", "retina", "retire", "return", - "reveal", "review", "revise", "revive", "revolt", "reward", - "rhino", "rhyme", "rhythm", "ribbon", "rice", "rich", "rick", - "rid", "ride", "rider", "ridge", "rife", "rifle", "rift", "right", - "rigid", "ring", "rinse", "riot", "ripe", "ripen", "ripple", - "rise", "risk", "risky", "rite", "ritual", "rival", "river", - "road", "roar", "roast", "rob", "robe", "robin", "robot", "robust", - "rock", "rocket", "rocky", "rod", "rode", "rodent", "rogue", - "role", "roll", "roof", "room", "root", "rope", "rose", "rosy", - "rome", "rosa", "russia", "pretty", "price", "pride", "priest", - "rotate", "rotor", "rotten", "rouge", "rough", "round", "route", - "rover", "row", "royal", "rubble", "ruby", "rudder", "rude", - "rugby", "ruin", "rule", "ruler", "rumble", "rump", "run", "rune", - "rung", "runway", "rural", "rush", "rust", "rustic", "rusty", - "sack", "sacred", "sad", "saddle", "sadism", "sadly", "safari", - "safe", "safely", "safer", "safety", "saga", "sage", "said", + "reveal", "review", "revise", "revive", "revolt", "reward", "rex", + "rhine", "rhino", "rhyme", "rhythm", "ribbon", "rice", "rich", + "rick", "rid", "ride", "rider", "ridge", "rife", "rifle", "rift", + "right", "rigid", "ring", "rinse", "riot", "ripe", "ripen", + "ripple", "rise", "risk", "risky", "rite", "ritual", "ritz", + "rival", "river", "road", "roar", "roast", "rob", "robe", "robert", + "robin", "robot", "robust", "rock", "rocket", "rocky", "rod", + "rode", "rodent", "rogue", "role", "roll", "roman", "rome", "roof", + "room", "root", "rope", "rosa", "rose", "rosy", "rotate", "rotor", + "rotten", "rouge", "rough", "round", "route", "rover", "row", + "royal", "rubble", "ruby", "rudder", "rude", "rugby", "ruin", + "rule", "ruler", "rumble", "rump", "run", "rune", "rung", "runway", + "rural", "rush", "russia", "rust", "rustic", "rusty", "sack", + "sacred", "sad", "saddle", "sadism", "sadly", "safari", "safe", + "safely", "safer", "safety", "saga", "sage", "sahara", "said", "sail", "sailor", "saint", "sake", "salad", "salary", "sale", - "saline", "sahara", "sam", "saturn", "saudi", "saxon", "scot", - "salt", "salty", "salute", "same", "sample", "sand", "sandy", - "sane", "sash", "satan", "satin", "satire", "sauce", "sauna", - "savage", "save", "say", "scale", "scalp", "scan", "scant", "scar", + "saline", "saliva", "salmon", "saloon", "salt", "salty", "salute", + "sam", "same", "sample", "sand", "sandy", "sane", "sash", "satan", + "satin", "satire", "saturn", "sauce", "saudi", "sauna", "savage", + "save", "saxon", "say", "scale", "scalp", "scan", "scant", "scar", "scarce", "scare", "scarf", "scary", "scene", "scenic", "scent", - "school", "scope", "score", "scorn", "scotch", "scout", "scrap", - "scream", "screen", "screw", "script", "scroll", "scrub", "scum", - "sea", "seal", "seam", "seaman", "search", "season", "seat", - "second", "secret", "sect", "sector", "secure", "see", "seed", - "seeing", "seek", "seem", "seize", "seldom", "select", "self", - "sell", "seller", "semi", "senate", "send", "senile", "senior", - "sense", "sensor", "sent", "sentry", "sequel", "serene", "serial", - "seoul", "somali", "sony", "soviet", "saliva", "salmon", "saloon", - "series", "sermon", "serum", "serve", "server", "set", "settle", - "seven", "severe", "sewage", "sex", "sexual", "sexy", "shabby", - "shade", "shadow", "shady", "shaft", "shaggy", "shah", "shake", - "shaky", "shall", "sham", "shame", "shape", "share", "shark", - "sharp", "shawl", "she", "shear", "sheen", "sheep", "sheer", - "sheet", "shelf", "shell", "sherry", "shield", "shift", "shine", - "shiny", "ship", "shire", "shirt", "shit", "shiver", "shock", - "shoe", "shook", "shoot", "shop", "shore", "short", "shot", - "should", "shout", "show", "shower", "shrank", "shrewd", "shrill", - "shrimp", "shrine", "shrink", "shrub", "shrug", "shut", "shy", - "shyly", "sick", "side", "siege", "sigh", "sight", "sigma", "sign", - "signal", "silent", "silk", "silken", "silky", "sill", "silly", - "silver", "simple", "simply", "since", "sinful", "sing", "singer", - "single", "sink", "sir", "siren", "sister", "sit", "site", "six", - "sixth", "sixty", "size", "sketch", "skill", "skin", "skinny", - "skip", "skirt", "skull", "sky", "slab", "slack", "slain", "slam", - "slang", "slap", "slate", "slater", "slave", "sleek", "sleep", - "sleepy", "sleeve", "slice", "slick", "slid", "slide", "slight", - "slim", "slimy", "sling", "slip", "slit", "slogan", "slope", - "sloppy", "slot", "slow", "slowly", "slug", "slum", "slump", - "smack", "small", "smart", "smash", "smear", "smell", "smelly", - "smelt", "smile", "smoke", "smoky", "smooth", "smug", "snack", - "snail", "snake", "snap", "snatch", "sneak", "snow", "snowy", - "snug", "soak", "soap", "sober", "soccer", "social", "sock", - "socket", "soda", "sodden", "sodium", "sofa", "soft", "soften", - "softly", "soggy", "soil", "solar", "sold", "sole", "solely", - "solemn", "solid", "solo", "solve", "some", "son", "sonar", - "sonata", "song", "sonic", "soon", "sooner", "soot", "soothe", - "sordid", "sore", "sorrow", "sorry", "sort", "soul", "sound", - "soup", "sour", "source", "space", "spade", "span", "spare", - "spark", "spain", "stalin", "sudan", "suez", "sunday", "sweden", - "spate", "speak", "spear", "speech", "speed", "speedy", "spell", - "spend", "sperm", "sphere", "spice", "spicy", "spider", "spiky", - "spill", "spin", "spinal", "spine", "spiral", "spirit", "spit", - "spite", "splash", "split", "spoil", "spoke", "sponge", "spoon", - "sport", "spot", "spouse", "spray", "spread", "spree", "spring", - "sprint", "spur", "squad", "square", "squash", "squat", "squid", - "stab", "stable", "stack", "staff", "stage", "stain", "stair", - "stake", "stale", "stall", "stamp", "stance", "stand", "staple", - "star", "starch", "stare", "stark", "start", "starve", "state", - "static", "statue", "status", "stay", "stead", "steady", "steak", - "steal", "steam", "steel", "steep", "steer", "stem", "stench", - "step", "stereo", "stern", "stew", "stick", "sticky", "stiff", - "stifle", "stigma", "still", "sting", "stint", "stir", "stitch", - "stock", "stocky", "stone", "stony", "stool", "stop", "store", - "storm", "stormy", "story", "stout", "stove", "strain", "strait", - "strand", "strap", "strata", "straw", "stray", "streak", "stream", - "street", "stress", "strict", "stride", "strife", "strike", - "string", "strip", "strive", "stroke", "stroll", "strong", "stud", - "studio", "study", "stuff", "stuffy", "stunt", "stupid", "sturdy", - "style", "submit", "subtle", "subtly", "suburb", "such", "suck", - "sudden", "sue", "suffer", "sugar", "suit", "suite", "suitor", - "sullen", "sultan", "sum", "summer", "summit", "summon", "sun", + "school", "scope", "score", "scorn", "scot", "scotch", "scout", + "scrap", "scream", "screen", "screw", "script", "scroll", "scrub", + "scum", "sea", "seal", "seam", "seaman", "search", "season", + "seat", "second", "secret", "sect", "sector", "secure", "see", + "seed", "seeing", "seek", "seem", "seize", "seldom", "select", + "self", "sell", "seller", "semi", "senate", "send", "senile", + "senior", "sense", "sensor", "sent", "sentry", "seoul", "sequel", + "serene", "serial", "series", "sermon", "serum", "serve", "server", + "set", "settle", "seven", "severe", "sewage", "sex", "sexual", + "sexy", "shabby", "shade", "shadow", "shady", "shaft", "shaggy", + "shah", "shake", "shaky", "shall", "sham", "shame", "shape", + "share", "shark", "sharp", "shawl", "she", "shear", "sheen", + "sheep", "sheer", "sheet", "shelf", "shell", "sherry", "shield", + "shift", "shine", "shiny", "ship", "shire", "shirt", "shit", + "shiver", "shock", "shoe", "shook", "shoot", "shop", "shore", + "short", "shot", "should", "shout", "show", "shower", "shrank", + "shrewd", "shrill", "shrimp", "shrine", "shrink", "shrub", "shrug", + "shut", "shy", "shyly", "sick", "side", "siege", "sigh", "sight", + "sigma", "sign", "signal", "silent", "silk", "silken", "silky", + "sill", "silly", "silver", "simple", "simply", "since", "sinful", + "sing", "singer", "single", "sink", "sir", "siren", "sister", + "sit", "site", "six", "sixth", "sixty", "size", "sketch", "skill", + "skin", "skinny", "skip", "skirt", "skull", "sky", "slab", "slack", + "slain", "slam", "slang", "slap", "slate", "slater", "slave", + "sleek", "sleep", "sleepy", "sleeve", "slice", "slick", "slid", + "slide", "slight", "slim", "slimy", "sling", "slip", "slit", + "slogan", "slope", "sloppy", "slot", "slow", "slowly", "slug", + "slum", "slump", "smack", "small", "smart", "smash", "smear", + "smell", "smelly", "smelt", "smile", "smoke", "smoky", "smooth", + "smug", "snack", "snail", "snake", "snap", "snatch", "sneak", + "snow", "snowy", "snug", "soak", "soap", "sober", "soccer", + "social", "sock", "socket", "soda", "sodden", "sodium", "sofa", + "soft", "soften", "softly", "soggy", "soil", "solar", "sold", + "sole", "solely", "solemn", "solid", "solo", "solve", "somali", + "some", "son", "sonar", "sonata", "song", "sonic", "sony", "soon", + "sooner", "soot", "soothe", "sordid", "sore", "sorrow", "sorry", + "sort", "soul", "sound", "soup", "sour", "source", "soviet", + "space", "spade", "spain", "span", "spare", "spark", "sparse", + "spasm", "spat", "spate", "speak", "spear", "speech", "speed", + "speedy", "spell", "spend", "sperm", "sphere", "spice", "spicy", + "spider", "spiky", "spill", "spin", "spinal", "spine", "spiral", + "spirit", "spit", "spite", "splash", "split", "spoil", "spoke", + "sponge", "spoon", "sport", "spot", "spouse", "spray", "spread", + "spree", "spring", "sprint", "spur", "squad", "square", "squash", + "squat", "squid", "stab", "stable", "stack", "staff", "stage", + "stain", "stair", "stake", "stale", "stalin", "stall", "stamp", + "stance", "stand", "staple", "star", "starch", "stare", "stark", + "start", "starve", "state", "static", "statue", "status", "stay", + "stead", "steady", "steak", "steal", "steam", "steel", "steep", + "steer", "stem", "stench", "step", "stereo", "stern", "stew", + "stick", "sticky", "stiff", "stifle", "stigma", "still", "sting", + "stint", "stir", "stitch", "stock", "stocky", "stone", "stony", + "stool", "stop", "store", "storm", "stormy", "story", "stout", + "stove", "strain", "strait", "strand", "strap", "strata", "straw", + "stray", "streak", "stream", "street", "stress", "strict", + "stride", "strife", "strike", "string", "strip", "strive", + "stroke", "stroll", "strong", "stud", "studio", "study", "stuff", + "stuffy", "stunt", "stupid", "sturdy", "style", "submit", "subtle", + "subtly", "suburb", "such", "suck", "sudan", "sudden", "sue", + "suez", "suffer", "sugar", "suit", "suite", "suitor", "sullen", + "sultan", "sum", "summer", "summit", "summon", "sun", "sunday", "sunny", "sunset", "super", "superb", "supper", "supple", "supply", "sure", "surely", "surf", "surge", "survey", "suture", "swamp", "swan", "swap", "swarm", "sway", "swear", "sweat", "sweaty", - "sweep", "sweet", "swell", "swift", "swim", "swine", "swing", - "swirl", "switch", "sword", "swore", "symbol", "synod", "syntax", - "swiss", "sydney", "syria", "taiwan", "sparse", "spasm", "spat", - "syrup", "system", "table", "tablet", "taboo", "tacit", "tackle", - "tact", "tactic", "tail", "tailor", "take", "tale", "talent", - "talk", "tall", "tally", "tame", "tandem", "tangle", "tank", "tap", - "tape", "target", "tariff", "tart", "task", "taste", "tarzan", - "taurus", "tehran", "teresa", "texas", "thomas", "tibet", "tokyo", - "tea", "teach", "teak", "team", "tear", "tease", "tech", "teeth", - "tell", "temper", "temple", "tempo", "tempt", "ten", "tenant", - "tend", "tender", "tendon", "tennis", "tenor", "tense", "tensor", - "tent", "tenth", "tenure", "term", "terror", "test", "text", - "than", "thank", "that", "the", "their", "them", "theme", "then", - "thence", "theory", "there", "these", "thesis", "they", "thick", - "thief", "thigh", "thin", "thing", "think", "third", "thirst", - "thirty", "this", "thorn", "those", "though", "thread", "threat", - "three", "thrill", "thrive", "throat", "throne", "throng", "throw", - "thrust", "thud", "thug", "thumb", "thus", "thyme", "tick", - "ticket", "tidal", "tide", "tidy", "tie", "tier", "tiger", "tight", - "tile", "till", "tilt", "timber", "time", "timid", "tin", "tiny", - "tip", "tissue", "title", "toad", "toast", "today", "toilet", - "token", "told", "toll", "tomato", "tomb", "tonal", "tone", - "tom", "turk", "tasty", "tattoo", "taut", "tavern", "tax", "taxi", - "tongue", "tonic", "too", "took", "tool", "tooth", "top", "topaz", - "topic", "torch", "torque", "torso", "tort", "toss", "total", - "touch", "tough", "tour", "toward", "towel", "tower", "town", - "toxic", "toxin", "trace", "track", "tract", "trade", "tragic", - "trail", "train", "trait", "tram", "trance", "trap", "trauma", - "travel", "tray", "tread", "treat", "treaty", "treble", "tree", - "trek", "tremor", "trench", "trend", "trendy", "trial", "tribal", - "tribe", "trick", "tricky", "tried", "trifle", "trim", "trio", - "trip", "triple", "troop", "trophy", "trot", "trough", "trout", - "truce", "truck", "true", "truly", "trunk", "trust", "truth", - "try", "tsar", "tube", "tumble", "tuna", "tundra", "tune", "tung", - "tunic", "tunnel", "turban", "turf", "turn", "turtle", "tutor", - "tweed", "twelve", "turkey", "uganda", "venice", "venus", "vienna", - "twin", "twist", "two", "tycoon", "tying", "type", "tyrant", - "ugly", "ulcer", "ultra", "umpire", "unable", "uncle", "under", - "uneasy", "unfair", "unify", "union", "unique", "unit", "unite", - "unity", "unlike", "unrest", "unruly", "until", "update", "upheld", + "sweden", "sweep", "sweet", "swell", "swift", "swim", "swine", + "swing", "swirl", "swiss", "switch", "sword", "swore", "sydney", + "symbol", "synod", "syntax", "syria", "syrup", "system", "table", + "tablet", "taboo", "tacit", "tackle", "tact", "tactic", "tail", + "tailor", "taiwan", "take", "tale", "talent", "talk", "tall", + "tally", "tame", "tandem", "tangle", "tank", "tap", "tape", + "target", "tariff", "tart", "tarzan", "task", "taste", "tasty", + "tattoo", "taurus", "taut", "tavern", "tax", "taxi", "tea", + "teach", "teak", "team", "tear", "tease", "tech", "teeth", + "tehran", "tell", "temper", "temple", "tempo", "tempt", "ten", + "tenant", "tend", "tender", "tendon", "tennis", "tenor", "tense", + "tensor", "tent", "tenth", "tenure", "teresa", "term", "terror", + "test", "texas", "text", "than", "thank", "that", "the", "their", + "them", "theme", "then", "thence", "theory", "there", "these", + "thesis", "they", "thick", "thief", "thigh", "thin", "thing", + "think", "third", "thirst", "thirty", "this", "thomas", "thorn", + "those", "though", "thread", "threat", "three", "thrill", "thrive", + "throat", "throne", "throng", "throw", "thrust", "thud", "thug", + "thumb", "thus", "thyme", "tibet", "tick", "ticket", "tidal", + "tide", "tidy", "tie", "tier", "tiger", "tight", "tile", "till", + "tilt", "timber", "time", "timid", "tin", "tiny", "tip", "tissue", + "title", "toad", "toast", "today", "toilet", "token", "tokyo", + "told", "toll", "tom", "tomato", "tomb", "tonal", "tone", "tongue", + "tonic", "too", "took", "tool", "tooth", "top", "topaz", "topic", + "torch", "torque", "torso", "tort", "toss", "total", "touch", + "tough", "tour", "toward", "towel", "tower", "town", "toxic", + "toxin", "trace", "track", "tract", "trade", "tragic", "trail", + "train", "trait", "tram", "trance", "trap", "trauma", "travel", + "tray", "tread", "treat", "treaty", "treble", "tree", "trek", + "tremor", "trench", "trend", "trendy", "trial", "tribal", "tribe", + "trick", "tricky", "tried", "trifle", "trim", "trio", "trip", + "triple", "troop", "trophy", "trot", "trough", "trout", "truce", + "truck", "true", "truly", "trunk", "trust", "truth", "try", "tsar", + "tube", "tumble", "tuna", "tundra", "tune", "tung", "tunic", + "tunnel", "turban", "turf", "turk", "turkey", "turn", "turtle", + "tutor", "tweed", "twelve", "twenty", "twice", "twin", "twist", + "two", "tycoon", "tying", "type", "tyrant", "uganda", "ugly", + "ulcer", "ultra", "umpire", "unable", "uncle", "under", "uneasy", + "unfair", "unify", "union", "unique", "unit", "unite", "unity", + "unlike", "unrest", "unruly", "until", "update", "upheld", "uphill", "uphold", "upon", "uproar", "upset", "upshot", "uptake", "upturn", "upward", "urban", "urge", "urgent", "urging", "urine", "usable", "usage", "use", "useful", "user", "usual", "uterus", "utmost", "utter", "vacant", "vacuum", "vagina", "vague", "vain", "valet", "valid", "valley", "value", "valve", "van", "vanish", "vanity", "vary", "vase", "vast", "vat", "vault", "vector", "veil", - "vein", "velvet", "vendor", "veneer", "venom", "vent", "venue", - "verb", "verbal", "verge", "verify", "verity", "verse", "versus", - "very", "vessel", "vest", "veto", "via", "viable", "vicar", "vice", - "victim", "victor", "video", "view", "vigil", "vile", "villa", - "viking", "virgo", "warsaw", "west", "yale", "twenty", "twice", - "vine", "vinyl", "viola", "violet", "violin", "viral", "virgin", - "virtue", "virus", "visa", "vision", "visit", "visual", "vital", - "vivid", "vocal", "vodka", "vogue", "voice", "void", "volley", - "volume", "vomit", "vote", "vowel", "voyage", "vulgar", "wade", - "wage", "waist", "wait", "waiter", "wake", "walk", "walker", - "wall", "wallet", "walnut", "wander", "want", "war", "warden", - "warm", "warmth", "warn", "warp", "wary", "was", "wash", "wasp", + "vein", "velvet", "vendor", "veneer", "venice", "venom", "vent", + "venue", "venus", "verb", "verbal", "verge", "verify", "verity", + "verse", "versus", "very", "vessel", "vest", "veto", "via", + "viable", "vicar", "vice", "victim", "victor", "video", "vienna", + "view", "vigil", "viking", "vile", "villa", "vine", "vinyl", + "viola", "violet", "violin", "viral", "virgin", "virgo", "virtue", + "virus", "visa", "vision", "visit", "visual", "vital", "vivid", + "vocal", "vodka", "vogue", "voice", "void", "volley", "volume", + "vomit", "vote", "vowel", "voyage", "vulgar", "wade", "wage", + "waist", "wait", "waiter", "wake", "walk", "walker", "wall", + "wallet", "walnut", "wander", "want", "war", "warden", "warm", + "warmth", "warn", "warp", "warsaw", "wary", "was", "wash", "wasp", "waste", "watch", "water", "watery", "wave", "way", "weak", "weaken", "wealth", "weapon", "wear", "weary", "wedge", "wee", "weed", "week", "weekly", "weep", "weight", "weird", "well", - "were", "wet", "whale", "wharf", "what", "wheat", "wheel", "when", - "whence", "where", "which", "whiff", "whig", "while", "whim", - "whip", "whisky", "white", "who", "whole", "wholly", "whom", - "whore", "whose", "why", "wide", "widely", "widen", "wider", - "widow", "width", "wife", "wild", "wildly", "wilful", "will", - "willow", "win", "wind", "window", "windy", "wine", "wing", "wink", - "winner", "winter", "wipe", "wire", "wisdom", "wise", "wish", - "wit", "witch", "with", "within", "witty", "wizard", "woke", - "wolf", "wolves", "woman", "womb", "won", "wonder", "wood", + "were", "west", "wet", "whale", "wharf", "what", "wheat", "wheel", + "when", "whence", "where", "which", "whiff", "whig", "while", + "whim", "whip", "whisky", "white", "who", "whole", "wholly", + "whom", "whore", "whose", "why", "wide", "widely", "widen", + "wider", "widow", "width", "wife", "wild", "wildly", "wilful", + "will", "willow", "win", "wind", "window", "windy", "wine", "wing", + "wink", "winner", "winter", "wipe", "wire", "wisdom", "wise", + "wish", "wit", "witch", "with", "within", "witty", "wizard", + "woke", "wolf", "wolves", "woman", "womb", "won", "wonder", "wood", "wooden", "woods", "woody", "wool", "word", "work", "worker", "world", "worm", "worry", "worse", "worst", "worth", "worthy", "would", "wound", "wrap", "wrath", "wreath", "wreck", "wright", "wrist", "writ", "write", "writer", "wrong", "xerox", "yacht", - "yard", "yarn", "yeah", "year", "yeast", "yellow", "yet", "yield", - "yogurt", "yolk", "you", "young", "your", "yemen", "york", "zaire", - "youth", "zeal", "zebra", "zenith", "zero", "zigzag", "zinc", - "zombie", "zone","zurich" + "yale", "yard", "yarn", "yeah", "year", "yeast", "yellow", "yemen", + "yet", "yield", "yogurt", "yolk", "york", "you", "young", "your", + "youth", "zaire", "zeal", "zebra", "zenith", "zero", "zigzag", + "zinc", "zombie", "zone", "zurich", ]; diff --git a/tests/test_lib.rs b/tests/test_lib.rs index 50983eb..1b7e955 100644 --- a/tests/test_lib.rs +++ b/tests/test_lib.rs @@ -33,10 +33,10 @@ mod tests { fn test_words() { let words = Words::new(); let new_words = words.words(); - + assert_eq!(new_words.words.len(), 0); } - + #[test] fn test_default() { let common = Common::default(); diff --git a/tests/test_macros.rs b/tests/test_macros.rs index 40edcdb..4f1c1ce 100644 --- a/tests/test_macros.rs +++ b/tests/test_macros.rs @@ -1,80 +1,115 @@ #[cfg(test)] mod tests { - - // Importing cmn crate and all of its macros + // Importing the cmn crate and all of its macros + use cmn::Common; use cmn::{ - cmn_assert, cmn_contains, cmn_join, cmn_max, cmn_min, - cmn_print, cmn_print_vec, cmn_split, cmn_vec, constants::*, + cmn_assert, cmn_contains, cmn_in_range, cmn_join, cmn_map, + cmn_max, cmn_min, cmn_parse, cmn_print, cmn_print_vec, + cmn_split, cmn_to_num, cmn_vec, constants::*, }; + /// Test that the `cmn_assert!` macro correctly triggers a panic when the argument is false. #[test] #[should_panic(expected = "Assertion failed!")] fn test_cmn_assert_fail() { - // Test that cmn_assert! macro correctly triggers a panic when the argument is false cmn_assert!(false); } + /// Test that the `cmn_assert!` macro does not trigger a panic when the argument is true. #[test] fn test_cmn_assert() { - // Test that cmn_assert! macro does not trigger a panic when the argument is true cmn_assert!(true); } + /// Test that the `cmn_contains!` macro correctly checks if the first string contains the second. + #[test] + fn test_cmn_contains() { + assert!(cmn_contains!("Hello", "H")); + assert!(!cmn_contains!("Hello", "x")); + } + + /// Test that the `cmn_in_range!` macro correctly checks if the value is within the given range. + #[test] + #[allow(clippy::assertions_on_constants)] + fn test_cmn_in_range() { + debug_assert!(cmn_in_range!(5, 0, 10)); + debug_assert!(!cmn_in_range!(15, 0, 10)); + } + + /// Test that the `cmn_join!` macro correctly joins the string arguments together. #[test] fn test_cmn_join() { - // Test that cmn_join! macro correctly joins the string arguments together let s = cmn_join!("Hello", " ", "World"); assert_eq!(s, "Hello World"); } + /// Test that the `cmn_map!` macro correctly creates a HashMap from the given key-value pairs. #[test] - fn test_cmn_min() { - // Test that cmn_min! macro correctly identifies the minimum value among the arguments - assert_eq!(cmn_min!(10, 20, 30), 10); + fn test_cmn_map() { + let map = cmn_map!("foo" => 1, "bar" => 2, "baz" => 3); + assert_eq!(map.get("foo"), Some(&1)); + assert_eq!(map.get("bar"), Some(&2)); + assert_eq!(map.get("baz"), Some(&3)); + assert_eq!(map.get("qux"), None); } + /// Test that the `cmn_max!` macro correctly identifies the maximum value among the arguments. #[test] fn test_cmn_max() { - // Test that cmn_max! macro correctly identifies the maximum value among the arguments assert_eq!(cmn_max!(10, 20, 30), 30); } + /// Test that the `cmn_min!` macro correctly identifies the minimum value among the arguments. + #[test] + fn test_cmn_min() { + assert_eq!(cmn_min!(10, 20, 30), 10); + } + + /// Test that the `cmn_parse!` macro correctly parses the input JSON string into a `Common` instance. + #[test] + fn test_cmn_parse() { + let json = r#"{"words": ["foo", "bar", "baz"]}"#; + let common = cmn_parse!(json).unwrap(); + let words_list = common.words().words_list(); + assert_eq!(words_list, vec!["bar", "baz", "foo"]); + } + + /// Test that the `cmn_print!` macro correctly prints the argument. #[test] fn test_cmn_print() { - // Test that cmn_print! macro correctly prints the argument cmn_print!("Hello, World!"); } + /// Test that the `cmn_print_vec!` macro correctly prints the elements of the vector argument. #[test] fn test_cmn_print_vec() { - // Test that cmn_print_vec! macro correctly prints the elements of the vector argument cmn_print_vec!(&[1, 2, 3]); } + /// Test that the `cmn_split!` macro correctly splits the string argument into a vector of words. #[test] fn test_cmn_split() { - // Test that cmn_split! macro correctly splits the string argument into a vector of words let v = cmn_split!("Hello World"); assert_eq!(v, vec!["Hello", "World"]); } + /// Test that the `cmn_to_num!` macro correctly converts a string to a number. #[test] - fn test_cmn_vec() { - // Test that cmn_vec! macro correctly creates a vector from the arguments - let v = cmn_vec!(1, 2, 3); - assert_eq!(v, &[1, 2, 3]); + fn test_cmn_to_num() { + assert_eq!(cmn_to_num!("42.5"), 42.5); + assert_eq!(cmn_to_num!("invalid"), 0.0); } + /// Test that the `cmn_vec!` macro correctly creates a vector from the arguments. #[test] - fn test_cmn_contains() { - // Test that cmn_contains! macro correctly checks if the first string contains the second - assert!(cmn_contains!("Hello", "H")); - assert!(!cmn_contains!("Hello", "x")); + fn test_cmn_vec() { + let v = cmn_vec!(1, 2, 3); + assert_eq!(v, &[1, 2, 3]); } + /// Test that each constant defined by the `cmn_constants!` macro has the expected value or is not empty. #[test] fn test_cmn_constants() { - // Test that each constant defined by the cmn_constants! macro has the expected value or is not empty assert_eq!( APERY, 1.2020569031595942, "APERY should have a specific value" @@ -151,7 +186,8 @@ mod tests { "PLANCK should have a specific value" ); assert_eq!( - PLANCK_REDUCED, 1.0545718176461565e-34, + PLANCK_REDUCED, + PLANCK / (2.0 * PI), "PLANCK_REDUCED should have a specific value" ); assert_eq!( @@ -185,7 +221,11 @@ mod tests { SQRT5, 2.236_067_977_499_79, "SQRT5 should have a specific value" ); - assert_eq!(TAU, 2.0 * PI, "TAU should have a specific value"); + assert_eq!( + TAU, + 2.0 * std::f64::consts::PI, + "TAU should have a specific value" + ); assert_eq!( VACUUM_PERMEABILITY, 1.25663706212e-6, "VACUUM_PERMEABILITY should have a specific value" diff --git a/tests/test_words.rs b/tests/test_words.rs index 06417c3..d7552b6 100644 --- a/tests/test_words.rs +++ b/tests/test_words.rs @@ -12,22 +12,38 @@ mod tests { } #[test] -fn test_default_words_list_order() { - let words = Words::default(); - let words_list = words.words_list(); - // Checking the first three elements to verify correct initialization and ordering - assert_eq!(words_list.len(), WORD_LIST.len(), "Default words list length should match WORD_LIST length."); - assert_eq!(words_list[0], "aboard", "Check that words list is sorted and starts with the first word."); - assert_eq!(words_list[1], "abode", "Check the second word in the sorted list."); - assert_eq!(words_list[2], "abort", "Check the third word in the sorted list."); -} + fn test_default_words_list_order() { + let words = Words::default(); + let words_list = words.words_list(); + // Checking the first three elements to verify correct initialization and ordering + assert_eq!( + words_list.len(), + WORD_LIST.len(), + "Default words list length should match WORD_LIST length." + ); + assert_eq!(words_list[0], "aboard", "Check that words list is sorted and starts with the first word."); + assert_eq!( + words_list[1], "abode", + "Check the second word in the sorted list." + ); + assert_eq!( + words_list[2], "abort", + "Check the third word in the sorted list." + ); + } #[test] fn test_add_word_and_contains() { let mut words = Words::new(); words.add_word("example"); - assert!(words.contains("example"), "Word 'example' should be found after adding."); - assert!(!words.contains("test"), "Word 'test' should not be found if not added."); + assert!( + words.contains("example"), + "Word 'example' should be found after adding." + ); + assert!( + !words.contains("test"), + "Word 'test' should not be found if not added." + ); } #[test] @@ -44,7 +60,11 @@ fn test_default_words_list_order() { let mut words = Words::new(); words.add_word("duplicate"); words.add_word("duplicate"); - assert_eq!(words.count(), 1, "Duplicates should not increase the count."); + assert_eq!( + words.count(), + 1, + "Duplicates should not increase the count." + ); } #[test] @@ -52,17 +72,32 @@ fn test_default_words_list_order() { let mut words = Words::default(); assert!(!words.words_list().is_empty(), "Words list should not be empty after initialization with default."); words.clear(); - assert!(words.words_list().is_empty(), "Words list should be empty after calling clear()."); + assert!( + words.words_list().is_empty(), + "Words list should be empty after calling clear()." + ); } #[test] fn test_remove_word() { let mut words = Words::new(); words.add_word("remove"); - assert!(words.contains("remove"), "Word 'remove' should be found after adding."); - assert!(words.remove_word("remove"), "remove_word() should return true if the word was removed."); - assert!(!words.contains("remove"), "Word 'remove' should not be found after removal."); - assert!(!words.remove_word("nonexistent"), "remove_word() should return false for a nonexistent word."); + assert!( + words.contains("remove"), + "Word 'remove' should be found after adding." + ); + assert!( + words.remove_word("remove"), + "remove_word() should return true if the word was removed." + ); + assert!( + !words.contains("remove"), + "Word 'remove' should not be found after removal." + ); + assert!( + !words.remove_word("nonexistent"), + "remove_word() should return false for a nonexistent word." + ); } #[test] @@ -72,8 +107,17 @@ fn test_default_words_list_order() { words.add_word("apple"); words.add_word("monkey"); let words_list = words.words_list(); - assert_eq!(words_list[0], "apple", "Words list should be sorted alphabetically."); - assert_eq!(words_list[1], "monkey", "Words list should be sorted alphabetically."); - assert_eq!(words_list[2], "zebra", "Words list should be sorted alphabetically."); + assert_eq!( + words_list[0], "apple", + "Words list should be sorted alphabetically." + ); + assert_eq!( + words_list[1], "monkey", + "Words list should be sorted alphabetically." + ); + assert_eq!( + words_list[2], "zebra", + "Words list should be sorted alphabetically." + ); } -} \ No newline at end of file +}