Struct doh::util::RaiiGuard [] [src]

pub struct RaiiGuard<E: FnOnce()> { /* fields omitted */ }

A RAII guard object, calling a function when it's created and when it's destroyed.

Examples

Turn off cursor for the object's lifetime, then turn it back on.

let _cursor = RaiiGuard::new(|| cursor_visibility(false),
                             || cursor_visibility(true));

println!("There is no cursor here.");
println!("Normally you'd use this if you had nonechoing keyboard input.");

println!("After this scope ends, the cursor will be restored,
          the exit method and point nonaffecting.");

Methods

impl<E: FnOnce()> RaiiGuard<E>
[src]

[src]

Create a guard, calling the start function immediately, delaying the end function till the object is dropped.

Trait Implementations

impl<E: FnOnce()> Drop for RaiiGuard<E>
[src]

[src]

Call the end function supplied in new().