上一页 1 ··· 54 55 56 57 58 59 60 61 62 ··· 499 下一页
摘要: fn multiply(x: i64, y: u8) -> i64 { return x * (y as i64); } Here we convert u8to i64, which is possible since i64has a wider range than u8; but you c 阅读全文
posted @ 2024-02-24 19:01 Zhentiw 阅读(39) 评论(0) 推荐(0)
摘要: https://doc.rust-lang.org/book/ch05-01-defining-structs.html struct ColorClassicStruct { red: i32, green: i32, blue: i32 } struct ColorTupleStruct(i32 阅读全文
posted @ 2024-02-23 19:11 Zhentiw 阅读(38) 评论(0) 推荐(0)
摘要: fn main() { let cat = ("Furry McFurson", 3.5); let (name, age) = cat; println!("{} is {} years old.", name, age); } Example 2: #[test] fn indexing_tup 阅读全文
posted @ 2024-02-23 19:04 Zhentiw 阅读(36) 评论(0) 推荐(0)
摘要: fn main() { let a = 0..100; if a.len() >= 100 { println!("Wow, that's a big array!"); } else { println!("Meh, I eat arrays like that for breakfast."); 阅读全文
posted @ 2024-02-23 18:57 Zhentiw 阅读(45) 评论(0) 推荐(0)
摘要: struct Rectangle { width: i32, height: i32 } impl Rectangle { // Only change the test functions themselves pub fn new(width: i32, height: i32) -> Self 阅读全文
posted @ 2024-02-23 18:50 Zhentiw 阅读(69) 评论(0) 推荐(0)
摘要: pub fn is_even(num: i32) -> bool { num % 2 == 0 } /* This attribute indicates that the following module is a conditional compilation module that shoul 阅读全文
posted @ 2024-02-23 18:46 Zhentiw 阅读(54) 评论(0) 推荐(0)
摘要: Code has error: fn main() { let answer = square(3); println!("The square of 3 is {}", answer); } fn square(num: i32) -> i32 { num * num; } Error: ⚠️ C 阅读全文
posted @ 2024-02-23 15:39 Zhentiw 阅读(37) 评论(0) 推荐(0)
摘要: Constants variable always need to be annotated: const NUMBER: i32 = 3; fn main() { println!("Number {}", NUMBER); } 阅读全文
posted @ 2024-02-23 15:02 Zhentiw 阅读(28) 评论(0) 推荐(0)
摘要: Ref to : https://doc.rust-lang.org/book/ch03-01-variables-and-mutability.html#shadowing fn main() { let number = "T-H-R-E-E"; // don't change this lin 阅读全文
posted @ 2024-02-23 14:59 Zhentiw 阅读(34) 评论(0) 推荐(0)
摘要: This lesson shows how to use a Rust loop to run a program infinitely. use std::io; use std::process; fn main() { loop { println!("Please enter a first 阅读全文
posted @ 2024-02-23 14:39 Zhentiw 阅读(29) 评论(0) 推荐(0)
上一页 1 ··· 54 55 56 57 58 59 60 61 62 ··· 499 下一页