pub struct Slot<T> { /* private fields */ }Expand description
A value of type T kept in a context’s temporary memory, by name.
Per context by default; Slot::keyed gives one value per key (a
widget’s id, a viewport). Names are unique across egui-pop and the
application, prefixed by the crate (core.slider.typing).
Implementations§
Source§impl<T: Clone + Send + Sync + 'static> Slot<T>
impl<T: Clone + Send + Sync + 'static> Slot<T>
Sourcepub const fn new(name: &'static str) -> Selfwhere
T: Debug,
pub const fn new(name: &'static str) -> Selfwhere
T: Debug,
A slot per context, its values summarised by their Debug form.
Sourcepub const fn summarised(name: &'static str, summary: fn(&T) -> String) -> Self
pub const fn summarised(name: &'static str, summary: fn(&T) -> String) -> Self
A slot per context whose values say themselves what the debug
bridge should read, when their Debug form would not fit in a
summary.
Sourcepub const fn opaque(name: &'static str) -> Self
pub const fn opaque(name: &'static str) -> Self
A slot per context whose values have no Debug form (handles,
trait objects): summarised by their type.
Sourcepub fn keyed(self, key: impl Hash + Debug) -> Self
pub fn keyed(self, key: impl Hash + Debug) -> Self
The same slot, one value per key (a widget’s id, a viewport).
Sourcepub fn get_or_default(&self, ctx: &Context) -> Twhere
T: Default,
pub fn get_or_default(&self, ctx: &Context) -> Twhere
T: Default,
The value, or T::default() (nothing is stored).
Sourcepub fn get_or_insert_with(&self, ctx: &Context, make: impl FnOnce() -> T) -> T
pub fn get_or_insert_with(&self, ctx: &Context, make: impl FnOnce() -> T) -> T
The value, created by make when there is none. make runs
outside egui’s lock: it may read the context.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Slot<T>
impl<T> RefUnwindSafe for Slot<T>
impl<T> Send for Slot<T>
impl<T> Sync for Slot<T>
impl<T> Unpin for Slot<T>
impl<T> UnsafeUnpin for Slot<T>
impl<T> UnwindSafe for Slot<T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more