将你要用的环境变量一次性导入到类型安全的Rust结构体中,感觉非常好用。
use serde::Deserialize;
#[derive(Deserialize, Debug)]
struct Config {
foo: u16,
bar: bool,
baz: String,
boom: Option<u64>
}
fn main() {
match envy::from_env::<Config>() {
Ok(config) => println!("{:#?}", config),
Err(error) => panic!("{:#?}", error)
}
}
https://github.com/softprops/envy
在默认情况下,不能。但是借助类型系统的辅助,我们只需要多付出一点努力,就可以在编译层面做到。来看看是怎么做的。
https://medium.com/@adetaylor/can-the-rust-type-system-prevent-deadlocks-9ae6e4123037
前段时间facebook开源了buck2构建系统,最近 steveklabnik 就在研究如何使用它来编译Rust.
https://steveklabnik.com/writing/using-cratesio-with-buck
Firebuild 0.8 发布,加入对Rust的支持。号称能加速10倍Rust编译。
https://balintreczey.hu/blog/improve-build-time-of-rust-java-and-intel-fortran-projects-with-firebuilds-new-release/
这篇文章讲得比较清晰:

https://bertptrs.nl/2023/04/27/how-does-async-rust-work.html
--
From 日报小组 Mike
社区学习交流平台订阅:
Rust.cc 论坛:支持 rss
微信公众号:Rust 语言中文社区
原文作者:Rust语言中文社区;如有侵权,请联系管理员删除。