Struct dui::element::guard::Guard
[−]
[src]
pub struct Guard<E: Element>(_);
Guards an element by effectively destroying it on drop.
This does not provide ownership semantics (like cell types or smart pointers), just a simple dropper for the wrapped element.
The programmer must make there's no copies of the element flying around the program.
It's recommended to use this only for resource elements (those elements that cannot be attached to a dialog in any meaningful way).
It's undefined behaviour to manually destroy a element that is wrapped within a guard, unless
the elements gets unwrap
ped before Drop
gets called. Consequently it is also undefined
behaviour to have two guards guarding the same element.
Please refer to the crate level documentation of IUP-Rust (the main doc page) for details on ownership of elements.
Methods
impl<E: Element> Guard<E>
[src]
pub fn new(element: E) -> Guard<E>
[src]
Creates a guard for the specified element.
pub fn unwrap(self) -> E
[src]
Forgets this guard and unwraps out the contained element.
Trait Implementations
impl<E: Debug + Element> Debug for Guard<E>
[src]
fn fmt(&self, __arg_0: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
impl<E: Element> Drop for Guard<E>
[src]
impl<E: Element> Deref for Guard<E>
[src]
Be careful on deferecing so you don't store another copy of the element somewhere.
type Target = E
The resulting type after dereferencing.
fn deref(&self) -> &E
[src]
Dereferences the value.
impl<E: Element> DerefMut for Guard<E>
[src]
Be careful on deferecing so you don't store another copy of the element somewhere.