pub struct AnyResolvable<T> { /* private fields */ }Expand description
A type-erased wrapper for any resolvable value.
AnyResolvable<T> allows storing different Resolvable implementations that all
resolve to the same output type T. This is essential for types like Color and
Font which can be constructed from many different sources (hex strings, theme
tokens, computed values) but all resolve to the same concrete type.
§Example
ⓘ
use waterui_core::resolve::AnyResolvable;
// These all resolve to ResolvedColor, but come from different sources
let from_hex = AnyResolvable::new(Srgb::from_hex("#FF0000"));
let from_token = AnyResolvable::new(theme::color::Accent);
let from_computed = AnyResolvable::new(some_color.lighten(0.2));Implementations§
Source§impl<T> AnyResolvable<T>
impl<T> AnyResolvable<T>
Sourcepub fn new(value: impl Resolvable<Resolved = T> + 'static) -> Self
pub fn new(value: impl Resolvable<Resolved = T> + 'static) -> Self
Sourcepub fn resolve(&self, env: &Environment) -> Computed<T>
pub fn resolve(&self, env: &Environment) -> Computed<T>
Trait Implementations§
Source§impl<T> Clone for AnyResolvable<T>
impl<T> Clone for AnyResolvable<T>
Source§impl<T: Debug> Debug for AnyResolvable<T>
impl<T: Debug> Debug for AnyResolvable<T>
Source§impl<T> Resolvable for AnyResolvable<T>where
T: 'static + Debug,
impl<T> Resolvable for AnyResolvable<T>where
T: 'static + Debug,
Auto Trait Implementations§
impl<T> Freeze for AnyResolvable<T>
impl<T> !RefUnwindSafe for AnyResolvable<T>
impl<T> !Send for AnyResolvable<T>
impl<T> !Sync for AnyResolvable<T>
impl<T> Unpin for AnyResolvable<T>
impl<T> !UnwindSafe for AnyResolvable<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