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);}}
本文对比四篇论文:
[1] Gaussian Splatting SLAM [2] SplaTAM: Splat, Track & Map 3D Gaussians for Dense RGB-D SLAM [3] Gaussian-SLAM: Photo-realistic Dense SLAM with Gaussian Splatting [4] GS-SLAM: Dense Visual SLAM with 3D Gaussian Splatting …
VSCode 介绍
Visual Studio Code(简称VSCode)是一个由微软开发的免费、开源的代码编辑器。VSCode是一个轻量级但是非常强大的代码编辑器,它支持多种编程语言(如C,C#,Java,Python,PHP࿰…