pub struct SingleUse<T>(_);
Expand description
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 = selector.with(SingleUse::new(num));
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§
Auto Trait Implementations§
impl<T> RefUnwindSafe for SingleUse<T>
impl<T> Send for SingleUse<T>where T: Send,
impl<T> Sync for SingleUse<T>where T: Send,
impl<T> Unpin for SingleUse<T>where T: Unpin,
impl<T> UnwindSafe for SingleUse<T>
Blanket Implementations§
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
§impl<T> RoundFrom<T> for T
impl<T> RoundFrom<T> for T
§fn round_from(x: T) -> T
fn round_from(x: T) -> T
Performs the conversion.
§impl<T, U> RoundInto<U> for Twhere
U: RoundFrom<T>,
impl<T, U> RoundInto<U> for Twhere U: RoundFrom<T>,
§fn round_into(self) -> U
fn round_into(self) -> U
Performs the conversion.