pub struct Once<T>(_);
Expand description
Special user-data wrapper intended for objects that can only be used once. Only
implements MapOwned
.
Trait Implementations
sourceimpl<T> MapOwned for Once<T>where
T: NativeClass + Send,
impl<T> MapOwned for Once<T>where
T: NativeClass + Send,
sourcefn map_owned<F, U>(&self, op: F) -> Result<U, Self::Err>where
F: FnOnce(Self::Target) -> U,
fn map_owned<F, U>(&self, op: F) -> Result<U, Self::Err>where
F: FnOnce(Self::Target) -> U,
Maps a T
to U
. Called for methods that take self
. This method may fail with
an error if it is called more than once on the same object.
Implementations of this method must not panic. Failures should be indicated by
returning Err
.
type Err = ValueTaken
sourceimpl<T> UserData for Once<T>where
T: NativeClass + Send,
impl<T> UserData for Once<T>where
T: NativeClass + Send,
type Target = T
sourcefn new(val: Self::Target) -> Self
fn new(val: Self::Target) -> Self
Creates a new owned wrapper from a
NativeClass
instance. Read moresourcefn into_user_data(self) -> *const c_void
fn into_user_data(self) -> *const c_void
Takes a native instance and returns an opaque pointer that can be used to recover it. Read more
sourceunsafe fn consume_user_data_unchecked(ptr: *const c_void) -> Self
unsafe fn consume_user_data_unchecked(ptr: *const c_void) -> Self
Takes an opaque pointer produced by
into_user_data
and “consumes” it to produce the
original instance, keeping the reference count. Read moresourceunsafe fn clone_from_user_data_unchecked(ptr: *const c_void) -> Self
unsafe fn clone_from_user_data_unchecked(ptr: *const c_void) -> Self
Takes an opaque pointer produced by
into_user_data
and “clones” it to produce the
original instance, increasing the reference count. Read moreAuto Trait Implementations
impl<T> !RefUnwindSafe for Once<T>
impl<T> Send for Once<T>where
T: Send,
impl<T> Sync for Once<T>where
T: Send,
impl<T> Unpin for Once<T>
impl<T> !UnwindSafe for Once<T>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more