pub struct StaticCompositionLocal<T: Clone + 'static> { /* private fields */ }Expand description
A StaticCompositionLocal is a CompositionLocal that is optimized for values that are
unlikely to change. Unlike CompositionLocal, reads of a StaticCompositionLocal are not
tracked by the recomposition system, which means:
- Reading
.current()does NOT establish a subscription - Changing the provided value does NOT automatically invalidate readers
- This makes it more efficient for truly static values
This matches the API of Jetpack Compose’s staticCompositionLocalOf but with simplified
semantics. Use this for values that are guaranteed to never change during the lifetime of
the CompositionLocalProvider scope (e.g., application-wide constants, configuration)
Implementations§
Source§impl<T: Clone + 'static> StaticCompositionLocal<T>
impl<T: Clone + 'static> StaticCompositionLocal<T>
pub fn provides(&self, value: T) -> ProvidedValue
pub fn current(&self) -> T
pub fn default_value(&self) -> T
Trait Implementations§
Source§impl<T: Clone + Clone + 'static> Clone for StaticCompositionLocal<T>
impl<T: Clone + Clone + 'static> Clone for StaticCompositionLocal<T>
Source§fn clone(&self) -> StaticCompositionLocal<T>
fn clone(&self) -> StaticCompositionLocal<T>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<T: Clone + 'static> PartialEq for StaticCompositionLocal<T>
impl<T: Clone + 'static> PartialEq for StaticCompositionLocal<T>
impl<T: Clone + 'static> Eq for StaticCompositionLocal<T>
Auto Trait Implementations§
impl<T> Freeze for StaticCompositionLocal<T>
impl<T> !RefUnwindSafe for StaticCompositionLocal<T>
impl<T> !Send for StaticCompositionLocal<T>
impl<T> !Sync for StaticCompositionLocal<T>
impl<T> Unpin for StaticCompositionLocal<T>
impl<T> !UnwindSafe for StaticCompositionLocal<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
Mutably borrows from an owned value. Read more