Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Provide alternatives for std::lazy::SyncLazy type? #88

Closed
phil-opp opened this issue Oct 10, 2020 · 4 comments · Fixed by #89
Closed

Provide alternatives for std::lazy::SyncLazy type? #88

phil-opp opened this issue Oct 10, 2020 · 4 comments · Fixed by #89

Comments

@phil-opp
Copy link
Contributor

RFC rust-lang/rfcs#2788 introduced a (still unstable) std::lazy module. While the Lazy and OnceCell types of this module are also available in core, their Sync counterparts are not because of their Mutex dependency.

The spin crate already provides a spin::Once as an alternative to the std::lazy::SyncOnceCell type (albeit with a different API). It would be useful if it would also provide an alternative to the std::lazy::SyncLazy type. This way, we could avoid depending on the lazy_static crate.

@zesterer
Copy link
Collaborator

Do you think this could be implemented as a thin layer on top of Once, or perhaps even integrated into it? The only obstacle to that I can forsee is the take method but I could easily add support for something like that to Once.

@phil-opp
Copy link
Contributor Author

Yeah, I think it could be a thin wrapper around Once. I can prepare a PR if you like.

I don't think that the take method is needed for that, but it might be useful on its own.

@phil-opp
Copy link
Contributor Author

I opened a PR at #89. It's just a copy of the standard library implementation, so please let me know if you think that it needs some adjustments.

@zesterer
Copy link
Collaborator

Perhaps adjustments might be required in the future, but for now this good enough for inclusion. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants