Keats / validator

Simple validation for Rust structs
MIT License
1.97k stars 141 forks source link

Disable unnecessary/unused regex features #261

Closed jirutka closed 1 year ago

jirutka commented 1 year ago

Avoid unnecessary case-insensitive regexes

The case-insensitive flag (?i) requires regex with the unicode-case feature enabled which significantly increases the binary size and makes regex slower.

Disable unnecessary/unused regex features

regex crate with default features enabled is huge, it significantly increases the binary size and compile time.

Cargo features are additive, so once some feature is enabled anywhere in the dependency graph, there's no way to disable it, i.e. one (transitive) dependency infects the whole dependency graph.

Since #[validate(regex = "...")] takes a path to a static Regex instance, not regex as a string, users have to add the regex dependency to their Cargo.toml to use it. Therefore, this change shouldn't break backward compatibility.

Keats commented 1 year ago

Can you make the PR on the next branch?

jirutka commented 1 year ago

Can you make the PR on the next branch?

Ok, done.

jirutka commented 1 year ago

Thanks for merging! When can I expect a new release?

Keats commented 1 year ago

Not anytime soon, the plan is to rewrite the derive macro for the next version

jirutka commented 1 year ago

If it takes longer, why don’t you just release the new version now and rewrite the macros in the next one?