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

Refactor browser and metal examples to use OnceCell #498

Merged
merged 1 commit into from
Sep 3, 2023

Conversation

silvanshade
Copy link
Contributor

This PR refactors the browser and metal examples to use OnceCell instead of RefCell.

I feel this is a more precise representation of how those ivars are used since they are intended to only be initialized once, and it should be an error to try and set them again (in this case, although in other scenarios RefCell could certainly make sense).

As a nice side effect, it should be a little more efficient and we don't seem to need the inner Option either.

@silvanshade silvanshade force-pushed the example-refactoring-once-cell branch 3 times, most recently from 7761d9b to 1759f43 Compare September 3, 2023 19:20
@madsmtm madsmtm added documentation Improvements or additions to documentation enhancement New feature or request A-framework Affects the framework crates and the translator for them labels Sep 3, 2023
Copy link
Owner

@madsmtm madsmtm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ohh nice, since it's so newly stabilized I hadn't really internalized that OnceCell exist

crates/icrate/examples/browser.rs Outdated Show resolved Hide resolved
crates/icrate/examples/browser.rs Outdated Show resolved Hide resolved
@madsmtm madsmtm merged commit 7e58561 into madsmtm:master Sep 3, 2023
19 checks passed
@silvanshade silvanshade deleted the example-refactoring-once-cell branch September 3, 2023 22:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-framework Affects the framework crates and the translator for them documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants