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

Switch from lazy_static to once_cell #1400

Merged
merged 3 commits into from
Dec 31, 2020
Merged

Switch from lazy_static to once_cell #1400

merged 3 commits into from
Dec 31, 2020

Conversation

jplatte
Copy link
Contributor

@jplatte jplatte commented Dec 30, 2020

This also changes the MSRV from 1.34.0 to 1.36.0.

Closes #1399.

Looks like with both the old and new MSRV, the crate could also switch to edition 2018. Would you like another PR for that?

This also changes the MSRV from 1.34.0 to 1.36.0.
@sfackler
Copy link
Owner

Would you like another PR for that?

Yes please!

pub static ref HOSTNAME_IDX: Index<Ssl, String> = Ssl::new_ex_index().unwrap();
}
pub static HOSTNAME_IDX: Lazy<Index<Ssl, String>> =
Lazy::new(|| Ssl::new_ex_index().unwrap());
Copy link
Owner

@sfackler sfackler Dec 31, 2020

Choose a reason for hiding this comment

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

If you use use a OnceCell instead you can use get_or_try_init to avoid the unwrap here: https://docs.rs/once_cell/1.5.2/once_cell/sync/struct.OnceCell.html#method.get_or_try_init

so some initialization errors don't result in a panic.
@sfackler sfackler merged commit d68077d into sfackler:master Dec 31, 2020
@jplatte jplatte deleted the once_cell branch December 31, 2020 14:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Switch from lazy_static to once_cell
2 participants