Sorry, your browser cannot access this site
This page requires browser support (enable) JavaScript
Learn more >

_x 会将值绑定到变量,而 _ 则完全不会绑定: let s = Some(String::from("Hello!")); if let Some(_s) = s { println!("found a string"); } println!("{:?}", s); s 是一...

if elseif else语句块是表达式 fn main() { let condition = true; let number = if condition { 5 } else { 6 }; println!("The value of number ...

内存布局struct File { name: String, data: Vec<u8>, } fn main() { let f1 = File { name: String::from("f1.txt"), data: Vec::new(), }; &#...

学习自 rust圣经 切片:全在栈上的对象,一个指针+一个长度 fn main() { let s = String::from("hello world"); let hello = &s[0..5]; let world = &s[6..11]; } world: 四种不同的类型:String(如上图的s),&...

学习自 rust圣经 强烈建议:https://gcc.godbolt.org/ 看反汇编注意,下文的“新建栈上对象”,其实不是“申请”,而是机器代码控制,在函数体对应的机器代码之前,栈顶就保留了足够长的栈,然后栈底+offset是栈上对象的起始地址 rust所有权规则 每一个值(内存对象)都被一个变量所拥有,该变量被称为值的所有者 一个值(内存对象)同时(同一个作用域内)只能被一个变量...

入门学习:rust语言圣经 https://course.rs/first-try/editor.html

cargo run 编译运行cargo run 首先对项目进行编译,然后再运行默认是debug模式,在这种模式下,代码的编译速度会非常快,运行速度就慢了. 原因是,在 debug 模式下,Rust 编译器不会做任何的优化高性能:cargo run --release cargo check 检查能否通过编译cargo check快速的检查一下代码能否编译通过。因此该命令速度会非常快,能节省大...