Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Consider using once_cell instead of lazy_static #124

Closed
lopopolo opened this issue Sep 2, 2022 · 3 comments · Fixed by #126
Closed

Consider using once_cell instead of lazy_static #124

lopopolo opened this issue Sep 2, 2022 · 3 comments · Fixed by #126
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@lopopolo
Copy link
Contributor

lopopolo commented Sep 2, 2022

Hi @BurntSushi, I don't currently use the unicode feature but I am looking to do so. bstr would be the only crate in my lockfile that uses lazy_static. There has been a lot of movement in the ecosystem to port over to once_cell. I personally think the API is nicer and the maintenance status is in a better spot.

once_cell has the added benefit of being slated for inclusion into std, which means it has the potential to simply re-export those std types once they are stabilized.

once_cell's MSRV is in the 1.36 range, which is compatible with the 1.60 MSRV bstr now has.

rustc is also suggesting once_cell for statics:

Here's some examples throughout the ecosystem:

@lopopolo
Copy link
Contributor Author

lopopolo commented Sep 2, 2022

Now that I've taken a peek at this it looks like this update would need to be made to ucd-generate.

@BurntSushi
Copy link
Owner

Right. The main reason why I haven't done this yet is that I just don't think it matters much. And with it coming to std, doing a migration to once_cell before std just seemed like churn. So I left well enough alone.

With that said, if someone wanted to submit patches to ucd-generate and then bstr, I'd do my best to get them merged.

I do expect that eventually, Real Soon Now, once regex-automata 0.3 is out, it will have its own built-in synchronization mechanism for initializing DFAs lazily (and in a way that works without std). So if you wait long enough, the lazy_static dependency should just disappear (and won't even be replaced by once_cell). But I don't know when that will be. Maybe within the calendar year?

@BurntSushi BurntSushi added enhancement New feature or request help wanted Extra attention is needed good first issue Good for newcomers labels Sep 2, 2022
@lopopolo
Copy link
Contributor Author

lopopolo commented Sep 2, 2022

Awesome. The changes to regex-automata sound exciting! I'm happy to wait this one out.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants