jsonwebtoken icon indicating copy to clipboard operation
jsonwebtoken copied to clipboard

Validation: `required_spec_claims` HashSet should use a non-allocating value type.

Open fetchfern opened this issue 1 year ago • 1 comments

I can't see any reason why required_spec_claims couldn't be a HashSet<&'static str>, or, even better, use an enum instead.

Using a String as the value type leads to unnecessary allocations as well as assigning to that field being rather unergonomic. Having to convert your &'static strs to owned strings is annoying and wasteful.

Current workaround is to just not use the feature.

fetchfern avatar Apr 18 '24 07:04 fetchfern

I don't remember why it's that way but Validation has been like that for >7 years. In practice I think most users create a Validation struct once in their program and re-use it (the original intended use) so allocations are not an issue in that case

Keats avatar Apr 19 '24 11:04 Keats