If your function panics because of invalid inputs or invalid state that was caller’s responsibility to uphold, add #[track_caller] to the function. It will change displayed location of the panic to the the caller’s location, so that they can see where they have messed up.
If your function panics because of invalid inputs or invalid state that was caller’s responsibility to uphold, add
#[track_caller]
to the function. It will change displayed location of the panic to the the caller’s location, so that they can see where they have messed up.🤯 I had no idea this was a thing! Would’ve helped me track down quite a few errors.
https://blog.rust-lang.org/2020/08/27/Rust-1.46.0.html#track_caller