jonhoo / haphazard

Hazard pointers in Rust.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Static unique domains

MatthewPomes-Eaton opened this issue · comments

The current implementation of the unique_domain macro makes it impossible to assign such a domain to a static variable.

Ideally, I'd like to be able to write something like this:

static GLOBAL_DOMAIN: Domain<_> = unique_domain!();

However, Rust doesn't support wildcards in const/static types, and for I can't name the family type.

One simple solution would be to provide a similar macro for declaring static domains, which would look like this:

unique_domain!(static GLOBAL_DOMAIN);

Since the macro can name the family type, this doesn't pose any issues. I'd be happy to submit a PR if this is a desired feature.

That sounds like a great idea! I think there are some details to be worked out, but probably easiest to do so via a PR so we can talk about the actual code. We'll probably want to have two different macros, one for producing a value and one for producing a type, but that we can also take in the PR!