fndivide(x:f64, y:f64)->Option<f64>{if y ==0.0{None}else{Some(x / y)}}fnmain(){let result =divide(10.0,2.0);match result {Some(value)=>println!("Result: {}", value),None=>println!("Cannot divide by zero!"),}}
数组的使用
fnmain(){// 编译器自动推导出one的类型let one =[1,2,3];// 显式类型标注let two:[u8;3]=[1,2,3];let blank1 =[0;3];let blank2:[u8;3]=[0;3];// arrays是一个二维数组,其中每一个元素都是一个数组,元素类型是[u8; 3]let arrays:[[u8;3];4]=[one, two, blank1, blank2];// 借用arrays的元素用作循环中for a in&arrays {print!("{:?}: ", a);// 将a变成一个迭代器,用于循环// 你也可以直接用for n in a {}来进行循环for n in a.iter(){print!("\t{} + 10 = {}", n, n+10);}letmut sum =0;// 0..a.len,是一个 Rust 的语法糖,其实就等于一个数组,元素是从0,1,2一直增加到到a.len-1for i in0..a.len(){sum += a[i];}println!("\t({:?} = {})", a, sum);}}
【From Accelerated to Operating Conditions: How Trapped Charge Impacts on TDDB in SiO2 and HfO2 Stacks】 文章总结:
本研究深入探讨了在SiO2和HfO2介质堆叠中,陷阱电荷对时间依赖介电击穿(TDDB)现象的影响。通过引入载流子…