1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
/// A marker trait for data that can persist through the entire lifetime of a
/// component, usually through a hook.
///
/// This means, even if a struct with this trait itself is dropped, the
/// underlying data is still available in the memory until the component is
/// unmounted by React or replaced by some other data.
///
/// Cloning a struct with this trait will not duplicate the underlying data, but
/// only a pointer, so cloning is a fast way to make the underlying data
/// available for a closure, by moving a clone of the pointer inside it.
pub trait Persisted: Clone + 'static {
#[doc(hidden)]
fn ptr(&self) -> PersistedOrigin;
}
#[doc(hidden)]
#[non_exhaustive]
pub struct PersistedOrigin;