| Crates.io | cargo-what |
| lib.rs | cargo-what |
| version | 0.1.3 |
| created_at | 2020-10-17 15:20:42.949788+00 |
| updated_at | 2020-10-19 06:50:59.257355+00 |
| description | Tells you what type things are |
| homepage | |
| repository | https://github.com/geky/cargo-what |
| max_upload_size | |
| id | 301450 |
| size | 30,332 |
Tells you what type things are.
This crate provides the what! macro. This is functionally similar to the
todo! macro, except that it also tells you type information.
fn hello() -> Result<(), Box<dyn Error>> {
what!()
}
Just like todo!, what! passes all type-checks and makes it easy to
write/build/test unfinished code. If it ever ends up in a compiled program,
attempted to execute a what! will panic.
The fun part happens when you run cargo what.
$ cargo what
hole: expecting `std::result::Result<(), Box<dyn std::error::Error>>`
--> src/hello.rs
|
2 | what!()
| ^^^^^^^
Unfortunately, custom diagnostics aren't really available to Rust libraries,
requiring the extra command. cargo what can be installed with cargo:
$ cargo install cargo-what
cargo what wraps cargo build to show the type-info of any what!s
you have in your code.
what! also accepts arguments and shows their types, which can be useful
for reducing the "unused variable" noise.
fn hello(a: usize, b: usize) -> usize {
let c = a..b;
what!(a, b, c)
}
And with cargo what:
$ cargo what
hole: expecting `usize`
--> src/hello.rs
|
3 | what!(a, b, c)
| ^^^^^^^^^^^^^^
|
= note: a is `usize`
= note: b is `usize`
= note: c is `std::ops::Range<usize>`
Emacs keybindings left as an exercise to the reader.