7个版本
0.1.6 | 2022年2月10日 |
---|---|
0.1.5 | 2021年9月8日 |
0.1.4 | 2021年8月30日 |
#1397 in 开发工具
45 每月下载量
24KB
101 代码行
ograc
好吧,看看。假设你有一些不那么正确的代码
use std::env;
use std::meme;
fn main() {
let cup_1 = Some(42);
let cup_2 = None;
let cup_3 = None;
mem::replace(&mut cup_1, &mut cup_2);
mem::replace(&mut cup_3, &mut cup_1);
mem::replace(&mut cup_2, &mut cup_3);
mem::replace(&mut cup_2, &mut cup_1);
mem::replace(&mut cup_1, &mut cup_3);
mem::replace(&mut cup_3, &mut cup_2);
mem::replace(&mut cup_2, &mut cup_1);
mem::replace(&mut cup_1, &mut cup_2);
mem::replace(&mut cup_3, &mut cup_1);
mem::replace(&mut cup_3, &mut cup_1);
// ...
}
而你,一个谦逊的程序员,有一个有限大小的终端窗口,你问 cargo
发生了什么
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ 🦞 ~/rip _ ☐ x ┃
┠──────────────────────────────────────────────────────────────────────────────┨
┃ $ cargo build▉ ┃
┃ ┃
┃ ┃
┃ ┃
┃ ┃
┃ ┃
┃ ┃
┃ ┃
┃ ┃
┃ ┃
┃ ┃
┃ ┃
┃ ┃
┃ ┃
┃ ┃
┃ ┃
┃ ┃
┃ ┃
┃ ┃
┃ ┃
┃ ┃
┃ ┃
┃ ┃
┃ ┃
┃ ┃
┃ ┃
┃ ┃
┃ ┃
┃ ┃
┃ ┃
┃ ┃
┃ ┃
┃ ┃
┃ ┃
┃ ┃
┃ ┃
┃ ┃
┃ ┃
┃ ┃
┃ ┃
┃ ┃
┃ ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
你会得到一些不太有帮助的输出。
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ 🦞 ~/rip _ ☐ x ┃
┠──────────────────────────────────────────────────────────────────────────────┨
┃ | ┃
┃ 14 | mem::replace(&mut cup_3, &mut cup_2); ┃
┃ | ^^^ use of undeclared crate or module `mem` ┃
┃ ┃
┃ error[E0433]: failed to resolve: use of undeclared crate or module `mem` ┃
┃ --> src/main.rs:15:5 ┃
┃ | ┃
┃ 15 | mem::replace(&mut cup_2, &mut cup_1); ┃
┃ | ^^^ use of undeclared crate or module `mem` ┃
┃ ┃
┃ error[E0433]: failed to resolve: use of undeclared crate or module `mem` ┃
┃ --> src/main.rs:16:5 ┃
┃ | ┃
┃ 16 | mem::replace(&mut cup_1, &mut cup_2); ┃
┃ | ^^^ use of undeclared crate or module `mem` ┃
┃ ┃
┃ error[E0433]: failed to resolve: use of undeclared crate or module `mem` ┃
┃ --> src/main.rs:17:5 ┃
┃ | ┃
┃ 17 | mem::replace(&mut cup_3, &mut cup_1); ┃
┃ | ^^^ use of undeclared crate or module `mem` ┃
┃ ┃
┃ error[E0433]: failed to resolve: use of undeclared crate or module `mem` ┃
┃ --> src/main.rs:18:5 ┃
┃ | ┃
┃ 18 | mem::replace(&mut cup_3, &mut cup_1); ┃
┃ | ^^^ use of undeclared crate or module `mem` ┃
┃ ┃
┃ warning: unused import: `std::env` ┃
┃ --> src/main.rs:1:5 ┃
┃ | ┃
┃ 1 | use std::env; ┃
┃ | ^^^^^^^^ ┃
┃ | ┃
┃ = note: `#[warn(unused_imports)]` on by default ┃
┃ ┃
┃ Some errors have detailed explanations: E0432, E0433. ┃
┃ For more information about an error, try `rustc --explain E0432`. ┃
┃ warning: `rip` (bin "rip") generated 1 warning ┃
┃ error: could not compile `rip` due to 11 previous errors; 1 warning emitte ┃
┃ ┃
┃ $ █ ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
比如,实际的错误代码行都没显示。最重要的错误信息已经看不见了。现在,当然,你可以向上滚动或什么的,但对于那些需要多次尝试才能使程序编译的人来说,这会很快变得很烦人。
肯定有更好的方法,对吧?这就是你为什么会用 ograc
的原因。
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ 🦞 ~/rip _ ☐ x ┃
┠──────────────────────────────────────────────────────────────────────────────┨
┃ $ cargo install ograc ┃
┃ Updating crates.io index ┃
┃ Downloaded ograc v0.1.0 ┃
┃ Downloaded 1 crate (2.4 KB) in 0.95s ┃
┃ Installing ograc v0.1.0 ┃
┃ Compiling memchr v2.4.1 ┃
┃ Compiling eyre v0.6.5 ┃
┃ Compiling indenter v0.3.3 ┃
┃ Compiling regex-syntax v0.6.25 ┃
┃ Compiling once_cell v1.8.0 ┃
┃ Compiling lazy_static v1.4.0 ┃
┃ Compiling aho-corasick v0.7.18 ┃
┃ Compiling regex v1.5.4 ┃
┃ Compiling ograc v0.1.0 ┃
┃ Finished release [optimized] target(s) in 7.68s ┃
┃ Installing /home/ben/.cargo/bin/ograc ┃
┃ Installed package `ograc v0.1.0` (executable `ograc`) ┃
┃ ┃
┃ $ ograc build▉ ┃
┃ ┃
┃ ┃
┃ ┃
┃ ┃
┃ ┃
┃ ┃
┃ ┃
┃ ┃
┃ ┃
┃ ┃
┃ ┃
┃ ┃
┃ ┃
┃ ┃
┃ ┃
┃ ┃
┃ ┃
┃ ┃
┃ ┃
┃ ┃
┃ ┃
┃ ┃
┃ ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
看!
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ 🦞 ~/rip _ ☐ x ┃
┠──────────────────────────────────────────────────────────────────────────────┨
┃ --> src/main.rs:13:5 ┃
┃ | ┃
┃ 13 | mem::replace(&mut cup_1, &mut cup_3); ┃
┃ | ^^^ use of undeclared crate or module `mem` ┃
┃ ┃
┃ error[E0433]: failed to resolve: use of undeclared crate or module `mem` ┃
┃ --> src/main.rs:12:5 ┃
┃ | ┃
┃ 12 | mem::replace(&mut cup_2, &mut cup_1); ┃
┃ | ^^^ use of undeclared crate or module `mem` ┃
┃ ┃
┃ error[E0433]: failed to resolve: use of undeclared crate or module `mem` ┃
┃ --> src/main.rs:11:5 ┃
┃ | ┃
┃ 11 | mem::replace(&mut cup_2, &mut cup_3); ┃
┃ | ^^^ use of undeclared crate or module `mem` ┃
┃ ┃
┃ error[E0433]: failed to resolve: use of undeclared crate or module `mem` ┃
┃ --> src/main.rs:10:5 ┃
┃ | ┃
┃ 10 | mem::replace(&mut cup_3, &mut cup_1); ┃
┃ | ^^^ use of undeclared crate or module `mem` ┃
┃ ┃
┃ error[E0433]: failed to resolve: use of undeclared crate or module `mem` ┃
┃ --> src/main.rs:9:5 ┃
┃ | ┃
┃ 9 | mem::replace(&mut cup_1, &mut cup_2); ┃
┃ | ^^^ use of undeclared crate or module `mem` ┃
┃ ┃
┃ error[E0432]: unresolved import `std::meme` ┃
┃ --> src/main.rs:2:5 ┃
┃ | ┃
┃ 2 | use std::meme; ┃
┃ | ^^^^^---- ┃
┃ | | | ┃
┃ | | help: a similar name exists in the module: `mem` ┃
┃ | no `meme` in the root ┃
┃ ┃
┃ warning: `rip` (bin "rip") generated 1 warning ┃
┃ error: could not compile `rip` due to 11 previous errors; 1 warning emitted ┃
┃ ┃
┃ $ ▉ ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
重要的错误就在你的提示符前面,一目了然,没有任何障碍。就这么简单。
感谢 Cecile Tonglet,她的 cargo-firstpage
直接激发了这一想法。
依赖关系
~2.2–3.5MB
~55K SLoC