rust 函数的使用
fn main() { println!("Hello, world!"); another_function(2,3); let y ={ let x =3; //表达式的结尾没有分号,如果在表达式的结尾加上分号,它就变成了语句,而语句不会返回值。 x+1 }; println!(" the value in main of y is {}",y); let x = five(); println!(" the value in main of x is {}",x); } // ->表示返回值后面加类型 //上面说了表达式没有分号,它还可以隐式的表示return 5 fn five()->i32 { 5 } //函数名小写中间加下划线 //大多数静态语言一样参数需要指定类型 fn another_function(x:i32,y:u32){ println!(" the value of x is {}",x); println!(" the value of y is {}",y); }
相关推荐
zhangxiafll 2020-11-13
svap 2020-11-09
viplinux 2020-10-28
Justhavefun 2020-10-22
lousir 2020-10-21
longzhiwen 2020-10-16
Justhavefun 2020-09-25
归去来兮 2020-09-18
zhouxiaojie 2020-09-16
gamedevd 2020-09-04
tkernel 2020-09-03
Trustport 2020-09-01
svap 2020-08-25
tkernel 2020-08-18
lihn 2020-08-18
归去来兮 2020-07-28
TianlangStudio 2020-07-18
iammjun 2020-07-07
Colourful 2020-07-03