Crates.io | assert_panic_free |
lib.rs | assert_panic_free |
version | 1.0.2 |
source | src |
created_at | 2021-03-03 16:52:04.62776 |
updated_at | 2021-03-03 17:00:09.042371 |
description | Assert that some code is panic-free. Fast to compile, no syn or macros etc... |
homepage | https://github.com/spacejam/assert_panic_free |
repository | https://github.com/spacejam/assert_panic_free |
max_upload_size | |
id | 363264 |
size | 3,729 |
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.
works when built with optimizations / release:
assert_panic_free::assert_panic_free(|| 32);
doesn't work:
assert_panic_free(|| panic!(":("));
Inspired by no_panic and panic_never but I wanted something that allowed for fine-grained panic reduction (like no_panic) but also something that compiled fast (like panic_never).