Rust 高级概念

•类型系统简介。
•字符串。
•迭代器。
•闭包。
•模块。

代码块和表达式

fn main() {    
	// 使用裸代码块同时执行多个任务   
	 let precompute = {     
	    let a = (-34i64).abs();     
	       let b = 345i64.pow(3);     
	          let c = 3;   
	               a + b + c    };  
  // match表达式  
    let result_msg = match precompute {      
    			  42 => "done",    
    		      a if a % 2 == 0 => "continue",    
    		        _ => panic!("Oh no !")   
    		        };   
    		     println!("{}", result_msg); } 
   b = a;
   }
fn compute(i: i32) -> i32 {   
	 2 * i
	 }
	 	
fn main() {    
		let result_msg = "done";   
		 // if表达式赋值    
		

你可能感兴趣的:(Rust,rust,开发语言,后端)