上一页 1 ··· 21 22 23 24 25 26 27 28 29 ··· 467 下一页
摘要: https://doc.rust-lang.org/std/string/struct.String.html#method.trim fn string_slice(arg: &str) { println!("{}", arg); } fn string(arg: String) { print 阅读全文
posted @ 2024-02-26 03:15 Zhentiw 阅读(7) 评论(0) 推荐(0) 编辑
摘要: Structs contain data, but can also have logic. In this exercise we have defined the Package struct and we want to test some logic attached to it. #[de 阅读全文
posted @ 2024-02-26 02:51 Zhentiw 阅读(5) 评论(0) 推荐(0) 编辑
摘要: https://doc.rust-lang.org/stable/book/ch05-01-defining-structs.html#creating-instances-from-other-instances-with-struct-update-syntax Similar to Javas 阅读全文
posted @ 2024-02-26 02:44 Zhentiw 阅读(6) 评论(0) 推荐(0) 编辑
摘要: 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 阅读(1) 评论(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 阅读(7) 评论(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 阅读(2) 评论(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 阅读(4) 评论(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 阅读(13) 评论(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 阅读(11) 评论(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 阅读(4) 评论(0) 推荐(0) 编辑
上一页 1 ··· 21 22 23 24 25 26 27 28 29 ··· 467 下一页