Bump MSRV to 1.80
This commit is contained in:
parent
8c36ed4900
commit
519947463f
11 changed files with 70 additions and 98 deletions
28
src/utils.rs
28
src/utils.rs
|
|
@ -1,32 +1,4 @@
|
|||
// A poly-fill for `lazy_cell`
|
||||
// Replace with std::sync::LazyLock when https://github.com/rust-lang/rust/issues/109736 is stabilized.
|
||||
|
||||
// This isn't used on every platform, which can come up as dead code warnings.
|
||||
#![allow(dead_code)]
|
||||
|
||||
use std::any::Any;
|
||||
use std::ops::Deref;
|
||||
use std::sync::OnceLock;
|
||||
|
||||
pub(crate) struct Lazy<T> {
|
||||
cell: OnceLock<T>,
|
||||
init: fn() -> T,
|
||||
}
|
||||
|
||||
impl<T> Lazy<T> {
|
||||
pub const fn new(f: fn() -> T) -> Self {
|
||||
Self { cell: OnceLock::new(), init: f }
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Deref for Lazy<T> {
|
||||
type Target = T;
|
||||
|
||||
#[inline]
|
||||
fn deref(&self) -> &'_ T {
|
||||
self.cell.get_or_init(self.init)
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE: This is `pub`, but isn't actually exposed outside the crate.
|
||||
// NOTE: Marked as `#[doc(hidden)]` and underscored, because they can be quite difficult to use
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue