let chains 的语法支持有望在 1.62 到到达稳定. 届时,下面的语法将会被支持.fn main() {
let outer_opt = Some(Some(1i32));
if let Some(inner_opt) = outer_opt
&& let Some(number) = inner_opt
&& number == 1
{
println!("Peek a boo");
}
}

原文链接:https://www.veloren.net/

github地址:https://github.com/p-e-w/savage
bash 脚本。use xshell::{cmd, Shell};
fn main() -> anyhow::Result<()> {
let sh = Shell::new()?;
let user = "matklad";
let repo = "xshell";
cmd!(sh, "git clone https://github.com/{user}/{repo}.git").run()?;
sh.change_dir(repo);
let test_args = ["-Zunstable-options", "--report-time"];
cmd!(sh, "cargo test -- {test_args...}").run()?;
let manifest = sh.read_file("Cargo.toml")?;
let version = manifest
.split_once("version = \"")
.and_then(|it| it.1.split_once('\"'))
.map(|it| it.0)
.ok_or_else(|| anyhow::format_err!("can't find version field in the manifest"))?;
cmd!(sh, "git tag {version}").run()?;
let dry_run = if sh.var("CI").is_ok() { None } else { Some("--dry-run") };
cmd!(sh, "cargo publish {dry_run...}").run()?;
Ok(())
}
原文作者:Rust语言中文社区;如有侵权,请联系管理员删除。