[−][src]Struct druid::SingleUse
A wrapper type for Command
payloads that should only be used once.
This is useful if you have some resource that cannot be cloned, and you wish to send it to another widget.
Examples
use druid::{Command, Selector, SingleUse, Target}; struct CantClone(u8); let selector = Selector::new("use-once"); let num = CantClone(42); let command = Command::new(selector, SingleUse::new(num), Target::Auto); let payload: &SingleUse<CantClone> = command.get_unchecked(selector); if let Some(num) = payload.take() { // now you own the data assert_eq!(num.0, 42); } // subsequent calls will return `None` assert!(payload.take().is_none());
Implementations
impl<T: Any> SingleUse<T>
[src]
pub fn new(data: T) -> Self
[src]
Create a new single-use payload.
pub fn take(&self) -> Option<T>
[src]
Takes the value, leaving a None in its place.
Auto Trait Implementations
impl<T> RefUnwindSafe for SingleUse<T>
[src]
impl<T> Send for SingleUse<T> where
T: Send,
[src]
T: Send,
impl<T> Sync for SingleUse<T> where
T: Send,
[src]
T: Send,
impl<T> Unpin for SingleUse<T> where
T: Unpin,
[src]
T: Unpin,
impl<T> UnwindSafe for SingleUse<T>
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> RoundFrom<T> for T
pub fn round_from(x: T) -> T
impl<T, U> RoundInto<U> for T where
U: RoundFrom<T>,
U: RoundFrom<T>,
pub fn round_into(self) -> U
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,