[rust-dev] Static initialisation of LinearMap
pwalton at mozilla.com
Tue Jul 2 09:15:21 PDT 2013
On 7/2/13 8:45 AM, Michael Neumann wrote:
> Am 02.07.2013 17:29, schrieb Alex Crichton:
>>> I was looking for something like: static h:HashMap<K,C> =
>>> Is this possible at all?
> What would be much easier is to use a sorted array and binary search for
> But sorting at compile time seams to be tricky, for simple values ok,
> but for more
> complex keys I think it's impossible.
A procedural macro (what we call a syntax extension) could do it. I've
been thinking for a while that we should have such a syntax extension in
the compiler. This is needed in Servo for "pre-interned identifiers":
think well-known DOM attributes like "id" or HTML elements like "img".
More information about the Rust-dev