Attribute Macro unimpl::unimpl

source ·
#[unimpl]
Expand description

Indicates unimplemented function by panicking with a message of not implemented: <function name> when the function is called.

This allows your code to provide required function implementations, which is useful if you are prototyping or implementing a trait that requires multiple methods which you don’t plan to implement.

Panics

This attribute generates a function body that immediately panics with not implemented: <function name> message. This allows you to quickly see which exact function is not implemented.

Examples

use unimpl::unimpl;

#[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");