### Install toolchains with mise
Source: https://github.com/artichoke/focaccia/blob/trunk/CONTRIBUTING.md
Run this command after activating mise to install the Rust, Ruby, and Node.js toolchains declared in mise.toml.
```sh
mise install
```
--------------------------------
### Install Node.js dependencies
Source: https://github.com/artichoke/focaccia/blob/trunk/CONTRIBUTING.md
Installs Node.js via mise and installs repository-local dependencies with pnpm. Required for formatting markdown, YAML, and YML files.
```sh
mise install
pnpm install
```
--------------------------------
### unicode_full_casecmp usage example
Source: https://github.com/artichoke/focaccia
Example usage of unicode_full_casecmp with assertions for equal, greater, and less orderings.
```rust
use core::cmp::Ordering;
use focaccia::unicode_full_casecmp;
assert_eq!(unicode_full_casecmp("MASSE", "Maße"), Ordering::Equal);
assert_eq!(unicode_full_casecmp("São Paulo", "Sao Paulo"), Ordering::Greater);
assert_eq!(unicode_full_casecmp("", "São Paulo"), Ordering::Less);
```
--------------------------------
### unicode_full_case_eq usage example
Source: https://github.com/artichoke/focaccia
Example usage of unicode_full_case_eq with assertions covering equal, unequal, ASCII fast path, length mismatch, and empty strings.
```rust
use focaccia::unicode_full_case_eq;
assert!(unicode_full_case_eq("MASSE", "Maße"));
assert!(!unicode_full_case_eq("São Paulo", "Sao Paulo"));
assert!(unicode_full_case_eq("aBcDeF", "abcdef")); // pure ASCII fast path
assert!(!unicode_full_case_eq("abcdef", "abcde")); // length mismatch
assert!(unicode_full_case_eq("", "")); // empty strings are equal
```
--------------------------------
### Build with mise
Source: https://github.com/artichoke/focaccia/blob/trunk/CONTRIBUTING.md
Installs the Rust crates specified in Cargo.toml and runs the build task.
```sh
mise run build
```
--------------------------------
### unicode_full_lithuanian_casecmp usage example
Source: https://github.com/artichoke/focaccia
Example of comparing strings with Lithuanian case folding. The first assertion expects Equal, the second expects Less.
```rust
use core::cmp::Ordering;
use focaccia::unicode_full_lithuanian_casecmp;
assert_eq!(unicode_full_lithuanian_casecmp("I\u{301}", "i\u{301}"), Ordering::Equal);
assert_eq!(unicode_full_lithuanian_casecmp("I\u{301}", "i\u{307}\u{301}"), Ordering::Less);
```
--------------------------------
### ascii_casecmp usage example
Source: https://github.com/artichoke/focaccia
Usage of ascii_casecmp with byte strings. Demonstrates equality, ordering, and length tiebreak behavior.
```rust
use core::cmp::Ordering;
use focaccia::ascii_casecmp;
assert_eq!(ascii_casecmp(b"Artichoke Ruby", b"artichoke ruby"), Ordering::Equal);
assert_eq!(ascii_casecmp(b"artichoke ruby", b"Artichoke"), Ordering::Greater);
assert_eq!(ascii_casecmp(b"abcdef", b"abcde"), Ordering::Greater); // length tiebreak
```
--------------------------------
### unicode_full_turkic_casecmp usage example
Source: https://github.com/artichoke/focaccia
Example usage of unicode_full_turkic_casecmp. Demonstrates equality for Turkish case folding and compatibility with full folding. Requires importing the function from focaccia.
```rust
use core::cmp::Ordering;
use focaccia::unicode_full_turkic_casecmp;
assert_eq!(unicode_full_turkic_casecmp("İstanbul", "istanbul"), Ordering::Equal);
assert_ne!(unicode_full_turkic_casecmp("İstanbul", "Istanbul"), Ordering::Equal);
// Largely compatible with full folding:
assert_eq!(unicode_full_turkic_casecmp("MASSE", "Maße"), Ordering::Equal);
```
--------------------------------
### unicode_full_turkic_case_eq usage example
Source: https://github.com/artichoke/focaccia
Example usage of unicode_full_turkic_case_eq. Demonstrates equality for Turkish case folding and compatibility with full folding. Requires importing the function from focaccia.
```rust
use focaccia::unicode_full_turkic_case_eq;
assert!(unicode_full_turkic_case_eq("İstanbul", "istanbul"));
assert!(!unicode_full_turkic_case_eq("İstanbul", "Istanbul"));
assert!(unicode_full_turkic_case_eq("MASSE", "Maße"));
```
--------------------------------
### unicode_full_lithuanian_case_eq usage example
Source: https://github.com/artichoke/focaccia
Example of checking equality with Lithuanian case folding. The first two assertions show expected results, and the third demonstrates case-insensitive comparison.
```rust
use focaccia::unicode_full_lithuanian_case_eq;
assert!(unicode_full_lithuanian_case_eq("I\u{301}", "i\u{301}"));
assert!(!unicode_full_lithuanian_case_eq("I\u{301}", "i\u{307}\u{301}"));
assert!(unicode_full_lithuanian_case_eq("MASSE", "Maße"));
```
--------------------------------
### ascii_case_eq usage example
Source: https://github.com/artichoke/focaccia
Usage of ascii_case_eq with byte strings. Demonstrates equality, length mismatch, and unchanged non-ASCII bytes.
```rust
use focaccia::ascii_case_eq;
assert!(ascii_case_eq(b"Artichoke Ruby", b"artichoke ruby"));
assert!(!ascii_case_eq(b"artichoke ruby", b"Artichoke")); // different lengths
assert!(ascii_case_eq(b"\u{FFFD}".as_bytes(), "\u{FFFD}".as_bytes())); // U+FFFD unchanged
```
--------------------------------
### CaseFold::case_eq usage with all folding strategies
Source: https://github.com/artichoke/focaccia
Example showing case_eq with Full, Ascii, Turkic, and Lithuanian strategies. Includes assertions for equality and inequality, including the Lithuanian dot handling.
```rust
use focaccia::CaseFold;
assert!(CaseFold::Full.case_eq("MASSE", "Maße"));
assert!(!CaseFold::Full.case_eq("São Paulo", "Sao Paulo"));
assert!(CaseFold::Ascii.case_eq("Crate: focaccia", "Crate: FOCACCIA"));
assert!(!CaseFold::Ascii.case_eq("Fabled", "failed"));
assert!(CaseFold::Turkic.case_eq("İstanbul", "istanbul"));
assert!(!CaseFold::Turkic.case_eq("İstanbul", "Istanbul"));
assert!(CaseFold::Lithuanian.case_eq("I\u{301}", "i\u{301}"));
assert!(!CaseFold::Lithuanian.case_eq("I\u{301}", "i\u{307}\u{301}"));
```
--------------------------------
### CaseFold::casecmp usage with Ascii folding
Source: https://github.com/artichoke/focaccia
Example using CaseFold::Ascii for ASCII-only case-insensitive comparison. Shows that 'Crate: focaccia' equals 'Crate: FOCACCIA' and 'Fabled' is less than 'failed'.
```rust
use core::cmp::Ordering;
use focaccia::CaseFold;
let fold = CaseFold::Ascii;
assert_eq!(fold.casecmp("Crate: focaccia", "Crate: FOCACCIA"), Ordering::Equal);
assert_eq!(fold.casecmp("Fabled", "failed"), Ordering::Less);
```
--------------------------------
### CaseFold::casecmp usage with Full folding
Source: https://github.com/artichoke/focaccia
Example using CaseFold::Full to compare strings case-insensitively. Shows that 'ß' is considered equal to 'ss' and that 'São Paulo' is greater than 'Sao Paulo'.
```rust
use core::cmp::Ordering;
use focaccia::CaseFold;
let fold = CaseFold::Full;
assert_eq!(fold.casecmp("MASSE", "Maße"), Ordering::Equal);
assert_eq!(fold.casecmp("São Paulo", "Sao Paulo"), Ordering::Greater);
```
--------------------------------
### CaseFold::casecmp usage with Turkic folding
Source: https://github.com/artichoke/focaccia
Example using CaseFold::Turkic, which handles the Turkish I differently. Shows that 'İstanbul' equals 'istanbul' but not 'Istanbul'.
```rust
use core::cmp::Ordering;
use focaccia::CaseFold;
let fold = CaseFold::Turkic;
assert_eq!(fold.casecmp("İstanbul", "istanbul"), Ordering::Equal);
assert_ne!(fold.casecmp("İstanbul", "Istanbul"), Ordering::Equal);
```
--------------------------------
### Run tests with cargo test filter
Source: https://github.com/artichoke/focaccia/blob/trunk/CONTRIBUTING.md
`cargo test` accepts a filter argument that limits test execution to tests that substring match. For example, to run all tests for ascii casecmp, use `cargo test ascii`.
```sh
cargo test ascii
```
--------------------------------
### Prefix enum definition
Source: https://github.com/artichoke/focaccia
Defines the result of the ASCII fast path comparison. Complete(Ordering) indicates the comparison was decided by ASCII prefixes, while Unicode(left, right) carries the remaining suffixes starting at the first non-ASCII byte.
```rust
pub(super) enum Prefix<'a> {
Complete(Ordering),
Unicode(&'a str, &'a str),
}
```
--------------------------------
### Run benchmarks with cargo bench
Source: https://github.com/artichoke/focaccia/blob/trunk/docs/benchmarks.md
Runs the case_mapping benchmark and writes CSV output to target/benchmarks/results.csv. The second command uses BENCH_FILTER, BENCH_MS, and BENCH_SAMPLES to select workloads and adjust timing.
```sh
mkdir -p target/benchmarks
cargo bench --bench case_mapping > target/benchmarks/results.csv
BENCH_FILTER=ascii_long BENCH_MS=50 BENCH_SAMPLES=11 cargo bench --bench case_mapping
```
--------------------------------
### Create and push a release tag
Source: https://github.com/artichoke/focaccia/blob/trunk/docs/publishing.md
Run these commands to create a signed tag for a release. The tag must match the exact vX.Y.Z form required by the publish workflow.
```sh
git switch trunk
git pull --ff-only
git tag -s "vX.Y.Z" -m "vX.Y.Z"
git push origin "vX.Y.Z"
```
--------------------------------
### Run validation commands
Source: https://github.com/artichoke/focaccia/blob/trunk/docs/automations/dependency-sweep.md
Run these commands to validate changes before opening a pull request. They format, lint, test, and package the project.
```sh
mise run fmt
mise run lint
mise run test
cargo package --allow-dirty
```
--------------------------------
### Run tests with mise
Source: https://github.com/artichoke/focaccia/blob/trunk/CONTRIBUTING.md
Use `mise run test` to run the test suite. Tests are run for every PR and all builds must pass before merging.
```sh
mise run test
```
--------------------------------
### Add Focaccia dependency to Cargo.toml
Source: https://github.com/artichoke/focaccia/blob/trunk/README.md
Adds the Focaccia crate version 2.6.0 as a dependency in Cargo.toml.
```toml
[dependencies]
focaccia = "2.6.0"
```
--------------------------------
### Import focaccia public API
Source: https://github.com/artichoke/focaccia
Shows the crate root imports for the public API: CaseFold, ascii_casecmp, ascii_case_eq, NoSuchCaseFoldingScheme, and UNICODE_VERSION.
```rust
use focaccia::CaseFold;
use focaccia::{ascii_casecmp, ascii_case_eq};
use focaccia::NoSuchCaseFoldingScheme;
use focaccia::UNICODE_VERSION;
```
--------------------------------
### Error handling pattern with CaseFold::try_from
Source: https://github.com/artichoke/focaccia
Shows how to resolve a folding strategy name with try_from, falling back to CaseFold::Full on error. Then uses case_eq to compare strings.
```rust
use core::convert::TryFrom;
use focaccia::CaseFold;
let fold = match CaseFold::try_from(Some("turkic")) {
Ok(fold) => fold,
Err(_) => CaseFold::Full, // unknown scheme, fall back to full folding
};
assert!(fold.case_eq("İstanbul", "istanbul"));
```
--------------------------------
### Full Unicode case folding with CaseFold::Full
Source: https://github.com/artichoke/focaccia/blob/trunk/README.md
Performs case-insensitive comparisons using full Unicode case folding. Demonstrates equality and ordering for non-ASCII strings.
```rust
use core::cmp::Ordering;
use focaccia::CaseFold;
let fold = CaseFold::Full;
assert_eq!(fold.casecmp("MASSE", "Maße"), Ordering::Equal);
assert_eq!(fold.casecmp("São Paulo", "Sao Paulo"), Ordering::Greater);
assert!(fold.case_eq("MASSE", "Maße"));
assert!(!fold.case_eq("São Paulo", "Sao Paulo"));
```
--------------------------------
### Update Unicode data
Source: https://github.com/artichoke/focaccia/blob/trunk/CONTRIBUTING.md
Downloads the current Unicode license and case-folding data and generates Rust lookup tables. Review changes before committing.
```sh
mise run unicode:update
mise run unicode:build
```
--------------------------------
### TryFrom match arms for NoSuchCaseFoldingScheme
Source: https://github.com/artichoke/focaccia
The canonical byte-slice conversion match in `src/lib.rs:454-470`. It maps `None` to `Full` and exact byte matches for `ascii`, `turkic`, and `lithuanian`; any other value returns `Err(NoSuchCaseFoldingScheme::new())`. There is no wildcard success arm.
```rust
match value {
None => Ok(Self::Full),
Some(scheme) if scheme == b"ascii" => Ok(Self::Ascii),
Some(scheme) if scheme == b"turkic" => Ok(Self::Turkic),
Some(scheme) if scheme == b"lithuanian" => Ok(Self::Lithuanian),
Some(_) => Err(NoSuchCaseFoldingScheme::new()),
}
```
--------------------------------
### ASCII case comparison on byte slices
Source: https://github.com/artichoke/focaccia/blob/trunk/README.md
Compares ASCII strings as byte slices using the free functions ascii_casecmp and ascii_case_eq.
```rust
use core::cmp::Ordering;
use focaccia::{ascii_casecmp, ascii_case_eq};
assert_eq!(ascii_casecmp(b"Artichoke Ruby", b"artichoke ruby"), Ordering::Equal);
assert!(ascii_case_eq(b"Artichoke Ruby", b"artichoke ruby"));
```
--------------------------------
### Common development tasks
Source: https://github.com/artichoke/focaccia/blob/trunk/CONTRIBUTING.md
Lists the common development tasks declared in mise.toml for building, testing, formatting, linting, and documentation.
```sh
mise run build
mise run test
mise run fmt
mise run fmt:check
mise run lint
mise run lint:clippy:restriction
mise run doc
mise run doc:open
```
--------------------------------
### TryFrom