First release.
Calculate the CSS specificity (a, b, c) of a selector — the Rust counterpart of the specificity npm package. For CSS linters, cascade analysis, devtools, and CSS-in-JS.
use specificity::{specificity, Specificity};
assert_eq!(specificity("#id .cls a"), Specificity::new(1, 1, 1));
assert_eq!(specificity(":is(.a, #b)"), Specificity::new(1, 0, 0)); // max of args
assert!(specificity("#id") > specificity(".a.b.c")); // Ordspecificity(selector)/specificity_list(list);SpecificityisOrd+Display- Spec-accurate:
:is/:not/:has/:nth-child(… of S)max-of-args,:where=0, pseudo-elements, namespaces, escapes,:global/:local - CSS comments stripped; pathological nesting handled (no stack overflow)
- Zero dependencies;
#![no_std]
Differential-tested against the real keeganstreet specificity (0 mismatches over 4312 selectors). Fills a real gap — no standalone specificity crate existed.