diff --git a/crates/bevy_reflect/Cargo.toml b/crates/bevy_reflect/Cargo.toml index 96884618458ee..a098d03f19e1f 100644 --- a/crates/bevy_reflect/Cargo.toml +++ b/crates/bevy_reflect/Cargo.toml @@ -29,7 +29,6 @@ bevy_ptr = { path = "../bevy_ptr", version = "0.12.0-dev" } erased-serde = "0.3" downcast-rs = "1.2" thiserror = "1.0" -once_cell = "1.11" serde = "1" smallvec = { version = "1.6", features = [ "serde", diff --git a/crates/bevy_reflect/src/utility.rs b/crates/bevy_reflect/src/utility.rs index 71f82539f114a..75ad95b376a96 100644 --- a/crates/bevy_reflect/src/utility.rs +++ b/crates/bevy_reflect/src/utility.rs @@ -2,11 +2,10 @@ use crate::TypeInfo; use bevy_utils::{FixedState, StableHashMap}; -use once_cell::race::OnceBox; use std::{ any::{Any, TypeId}, hash::BuildHasher, - sync::{PoisonError, RwLock}, + sync::{OnceLock, PoisonError, RwLock}, }; /// A type that can be stored in a ([`Non`])[`GenericTypeCell`]. @@ -89,7 +88,7 @@ mod sealed { /// ``` /// /// [`TypePath`]: crate::TypePath -pub struct NonGenericTypeCell(OnceBox); +pub struct NonGenericTypeCell(OnceLock); /// See [`NonGenericTypeCell`]. pub type NonGenericTypeInfoCell = NonGenericTypeCell; @@ -97,7 +96,7 @@ pub type NonGenericTypeInfoCell = NonGenericTypeCell; impl NonGenericTypeCell { /// Initialize a [`NonGenericTypeCell`] for non-generic types. pub const fn new() -> Self { - Self(OnceBox::new()) + Self(OnceLock::new()) } /// Returns a reference to the [`TypedProperty`] stored in the cell. @@ -107,7 +106,7 @@ impl NonGenericTypeCell { where F: FnOnce() -> T::Stored, { - self.0.get_or_init(|| Box::new(f())) + self.0.get_or_init(f) } }