Function assert_panic_free::assert_panic_free[][src]

pub fn assert_panic_free<R, F: FnOnce() -> R>(f: F) -> R

A lightweight higher-order-function that doesn’t compile if a function you pass to it might panic. This probably wont’ work unless you’re compiling your code with optimizations enabled.

Example

works when built with optimizations / release:

assert_panic_free::assert_panic_free(|| 32);

doesn’t work:

assert_panic_free(|| panic!(":("));