Skip to main content
AllDevToolsHub
Back to all patterns

Rust Crate Name

Validation

Validates a Rust crate name as accepted by crates.io.

/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/

How it works

Crate names must start with a letter, contain only alphanumeric, underscore, or hyphen, and be up to 64 characters. Case-insensitive uniqueness is enforced by crates.io.

Test Cases

Should Match

  • serde
  • tokio
  • actix-web
  • my_crate

Should NOT Match

  • 1crate
  • -bad
  • crate name

Quick Summary

Validates a Rust crate name (letter-led, alphanumeric/underscore/hyphen, ≤64 chars).