Skip to content

Suggestion: lookup table construction with const fnΒ #188

Open
@arucil

Description

Currently lookup tables are contructed with macros, where keys and values are almost literals. With constant functions, one can use a rich set of builtin constant expressions during the construction of lookup tables. For example,

const A: &str = "aaa";
const B: &str = "bbb";
const TABLE: Map<&'static str, i32> = phf_map(&[
  (A, 1 * 3 * 5),
  (B, [1,2,3,4].len() as i32),
]);

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions