Skip to content

Commit 38f6621

Browse files
Peternator7Peter Glotfelty
andauthored
Expound upon use_phf docs (#449)
Co-authored-by: Peter Glotfelty <[email protected]>
1 parent bb13390 commit 38f6621

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

strum_macros/src/lib.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,11 @@ fn debug_print_generated(ast: &DeriveInput, toks: &TokenStream) {
5151
/// See the [Additional Attributes](https://docs.rs/strum/latest/strum/additional_attributes/index.html)
5252
/// Section for more information on using this feature.
5353
///
54-
/// If you have a large enum, you may want to consider using the `use_phf` attribute here. It leverages
55-
/// perfect hash functions to parse much quicker than a standard `match`. (MSRV 1.46)
54+
/// If you have a large enum, you may want to consider using the `use_phf` attribute here.
55+
/// PHF (Perfect Hash Functions) use a hash lookup instead of a linear search that may perform faster
56+
/// for large enums. Note: as with all optimizations, you should test this for your specific usecase
57+
/// rather than just assume it will be faster. With SIMD + pipelining, linear string search (aka memcmp)
58+
/// can be very fast for enums with a surprisingly large number of enum variants.
5659
///
5760
/// The default error type is `strum::ParseError`. This can be overriden by applying both the
5861
/// `parse_err_ty` and `parse_err_fn` attributes at the type level. `parse_error_fn` should be a

0 commit comments

Comments
 (0)