
rust
乄浅醉
这个作者很懒,什么都没留下…
展开
-
Rust-lang(hello world)
最近,突然迷上了Rust!Rust在中国还是小众中的小众!有个一年不会更新一次的论坛,没有任何中文,资料,只能去死磕官方文档!这个就是我死磕官方文档的笔记,是笔记,笔记,不是翻译!install略过吧,官网一看就会安装!hello worldfn main(){ println!("{}","hello world"); }使用命令rustc main.rs 编译, ./main 运行。ca原创 2016-04-29 16:47:56 · 1028 阅读 · 0 评论 -
Rust-lang(hello world 续)
loop上面的例子只能猜测一次,然后程序就停掉了,现在我们想不停的重复猜测,这里就用到循环了,当我们猜测正确的时候停止循环!fn main() { println!("Hello, world!"); let secret_number = rand::thread_rng().gen_range(1,101); println!("Please gusses secret nu原创 2016-04-29 16:49:58 · 461 阅读 · 0 评论 -
Rust 变量
变量声明let x=5; let (x,y) = (1,2); //x=1 y=2 type annotationsRust 是强类型语言,我们可以在声明变量时指定类型,在编译的时候会被检查。x类型是 int 32位类型变量 i 表示有符号,u表示无符号整数 ,在Rust中可以声明 8 、 16、 32、 64位的整数let x: i32 = 5;let y = 5; //默认是 i32 Muta原创 2016-04-29 16:52:26 · 493 阅读 · 0 评论 -
Rust 函数
函数definedfn main() { print_sum(5, 6); }fn print_sum(x: i32, y: i32) { println!("sum is: {}", x + y); } 函数定义时必须声明变量的类型,变量之间用逗号分隔。返回值fn add_one(x: i32) -> i32 { x + 1 // 不可以加分号 }表达式与语句 (ex原创 2016-04-29 16:54:03 · 436 阅读 · 0 评论 -
Rust 基本类型
基本类型像其他语言一样,Rust同样在标准库中內建了许多基本类型。boollet x = true;let y: bool = false; charlet x = 'x'; let two_hearts = '��'; 数值类型Rust提供多种数值类型,如下:i8 i16 i32 i64 u8 u16 u32 u64 isize usize f32 f64Rust中,整数类型原创 2016-04-29 16:55:58 · 1450 阅读 · 0 评论