https://github.com/spacejam/assert_panic_free
https://github.com/spacejam/assert_panic_free
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/spacejam/assert_panic_free
- Owner: spacejam
- Created: 2021-03-03T16:52:49.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2021-03-03T17:00:18.000Z (over 5 years ago)
- Last Synced: 2025-04-12T01:22:28.642Z (about 1 year ago)
- Language: Rust
- Size: 2.93 KB
- Stars: 16
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# assert_panic_free
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:
```no_build
assert_panic_free::assert_panic_free(|| 32);
```
doesn't work:
```compile_fail
assert_panic_free(|| panic!(":("));
```
Inspired by [no_panic](https://github.com/dtolnay/no-panic) and [panic_never](https://github.com/japaric/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).