# `#[unimpl]`
[![CI](https://github.com/wiktor-k/unimpl/actions/workflows/ci.yml/badge.svg)](https://github.com/wiktor-k/unimpl/actions/workflows/ci.yml)
[![Crates.io](https://img.shields.io/crates/v/unimpl)](https://crates.io/crates/unimpl)
Better `unimplemented!` macro for function definitions.
This macro helps you iterate faster on your codebase giving you more
accurate feedback on which functions were called during tests. It's
most useful during development.
Without `unimpl` the exact reason needs to be specified explicitly
otherwise the error message is too generic:
```rust
use panic_message::panic_message;
fn func(a: u32) -> u32 {
unimplemented!();
}
let error = std::panic::catch_unwind(|| {
func(42);
}).unwrap_err();
// in a bigger codebase it's not clear which function was called
assert_eq!(panic_message(&error), "not implemented");
```
With `unimpl` the function name is automatically attached to the error
message and the function body can be completely omitted:
```rust
use unimpl::unimpl;
use panic_message::panic_message;
#[unimpl]
pub fn func(a: u32) -> u32; // function body is autogenerated
let error = std::panic::catch_unwind(|| {
func(42);
}).unwrap_err();
// function name is automatically appended
assert_eq!(panic_message(&error), "not implemented: func");
```
The macro can also be used inside `impl` blocks:
```rust
use unimpl::unimpl;
use panic_message::panic_message;
struct X;
impl X {
/// This is a func.
#[unimpl]
pub fn func(a: u32) -> u32;
}
let error = std::panic::catch_unwind(|| {
X::func(42);
}).unwrap_err();
assert_eq!(panic_message(&error), "not implemented: func");
```
## License
This project is licensed under either of:
- [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0),
- [MIT license](https://opensource.org/licenses/MIT).
at your option.
### Contribution
Unless you explicitly state otherwise, any contribution intentionally
submitted for inclusion in this crate by you, as defined in the
Apache-2.0 license, shall be dual licensed as above, without any
additional terms or conditions.