想用 Rust 写脚本吗?
rust-script ,可以在没有任何设置或编译步骤的情况下运行rust 文件和表达式。
也支持 依赖 crate
fn main() {
println!("{}", time::now().rfc822z());
}
https://rust-script.org/
https://github.com/fornwall/rust-script
rust-script ,可以在没有任何设置或编译步骤的情况下运行rust 文件和表达式。
rust
$ echo 'println!("Hello, World!");' > hello.rs
$ rust-script hello.rs
Hello, World!
也支持 依赖 crate
rust
#!/usr/bin/env rust-script
//! This is a regular crate doc comment, but it also contains a partial
//! Cargo manifest. Note the use of a *fenced* code block, and the
//! `cargo` "language".
//!
//! ```cargo
//! [dependencies]
//! time = "0.1.25"
//!
fn main() {
println!("{}", time::now().rfc822z());
}
```rust
$ rust-script now
Wed, 28 Oct 2020 00:38:45 +0100
https://rust-script.org/
https://github.com/fornwall/rust-script