Struct wayland_commons::ThreadGuard [−][src]
Stores a value in a threadafe container that only lets you access it from its owning thread
If the ThreadGuard is dropped from the wrong thread, the underlying value will be leaked.
Implementations
impl<T> ThreadGuard<T>
[src]
pub fn new(val: T) -> ThreadGuard<T>
[src]
Create a new ThreadGuard wrapper
impl<T: ?Sized> ThreadGuard<T>
[src]
pub fn get(&self) -> &T
[src]
Access the underlying value
Panics if done on the wrong thread
pub fn get_mut(&mut self) -> &mut T
[src]
Mutably access the underlying value
Panics if done on the wrong thread
pub fn try_get(&self) -> Option<&T>
[src]
Try to access the underlying value
Returns None
if done on the wrong thread
pub fn try_get_mut(&mut self) -> Option<&mut T>
[src]
Try to mutably access the underlying value
Returns None
if done on the wrong thread
Trait Implementations
impl<T: ?Sized> Drop for ThreadGuard<T>
[src]
impl<T: ?Sized> Send for ThreadGuard<T>
[src]
impl<T: ?Sized> Sync for ThreadGuard<T>
[src]
Auto Trait Implementations
impl<T: ?Sized> RefUnwindSafe for ThreadGuard<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T: ?Sized> Unpin for ThreadGuard<T> where
T: Unpin,
T: Unpin,
impl<T: ?Sized> UnwindSafe for ThreadGuard<T> where
T: UnwindSafe,
T: UnwindSafe,
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, 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>,