slice-patterns.mdcommit 024aa9a345e92aa1926517c4d9b16bd83e74c10d如果你想在一个切片或数组上匹配,你可以通过slice_patterns功能使用&:#![feature(slice_patterns)]fn main() { let v = vec!["match_this", "1"]; match &v[..] { ["match_this", second] => println!("The second element is {}", second), _ =>
既然我们对函数有了一定了解之后,那么学习下如何写注释是不错的。注释的作用在于它能够帮助其他的程序员更好的理解你的代码。而编译期通常会忽视他们。Rust 中有两种你应该学习的注释方式:行注释和文档注释。// Line comments are anything after ‘//’ and extend to the end of the line.let x = 5; // this is also a line comment.