Replies: 82 comments 46 replies
-
这本书学着学着我就笑起来了,太幽默了。作者大大厉害 |
Beta Was this translation helpful? Give feedback.
-
那你在后续章节得小心大话西游效应:随着你越来越成熟,看大话西游时就越来越想哭 :D |
Beta Was this translation helpful? Give feedback.
-
我单方面宣布,这一节不用看。 |
Beta Was this translation helpful? Give feedback.
-
非常棒,比官方版本的更容易入门,赞! |
Beta Was this translation helpful? Give feedback.
-
great daze! |
Beta Was this translation helpful? Give feedback.
-
看到你的骚话,感到学编程更快乐了。这次的rust肯定要好好学了(之前看过的都忘了 |
Beta Was this translation helpful? Give feedback.
-
我好像已经知道作者的为人了。。doge |
Beta Was this translation helpful? Give feedback.
-
看到 for index, item in Listobj.enumerate() 梦回 Python3 的元组拆包和enumerate组合。 |
Beta Was this translation helpful? Give feedback.
-
单方向宣布, 比官方版本的好多了, 语言幽默, 也不会让你觉得太过基础, 也不会太难! |
Beta Was this translation helpful? Give feedback.
-
不喜欢这种写作风格,废话太多 |
Beta Was this translation helpful? Give feedback.
-
喜欢这种写做风格,不枯燥。 |
Beta Was this translation helpful? Give feedback.
-
records.map(|field| field.trim()); 是否类似于Java的如下代码呢? records.map(field -> field.trim()); |
Beta Was this translation helpful? Give feedback.
-
作者这么可爱,一定是蓝孩子吧😍 |
Beta Was this translation helpful? Give feedback.
-
不知道是哪个插件导致的,出现了很多 : &str |
Beta Was this translation helpful? Give feedback.
-
这么有意思的书,有木有出版啊,想买纸质支持下 |
Beta Was this translation helpful? Give feedback.
-
开头看你用了 |
Beta Was this translation helpful? Give feedback.
-
record .split(',') .map(|field| field.trim()) .collect(); |
Beta Was this translation helpful? Give feedback.
-
方法语法:由于 Rust 没有继承,因此 Rust 不是传统意义上的面向对象语言,但是它却从 OO 语言那里偷师了方法的使用 record.trim(),record.split(',') 等。 这里面的OO 是 GO 吗 |
Beta Was this translation helpful? Give feedback.
-
发现一个小bug:
应该是 会识别为&str类型吧 |
Beta Was this translation helpful? Give feedback.
-
说真的,我开始并未对 Rust 多大兴趣,只是被作者开篇的字眼吸引进来的,所以就想再深入了解一下 Rust ,在此也要先感谢作者的无私! |
Beta Was this translation helpful? Give feedback.
-
为什么这样写: 而不是: |
Beta Was this translation helpful? Give feedback.
-
'就像优秀的“国外”课本一样'😂 |
Beta Was this translation helpful? Give feedback.
-
哈哈,好嘞,咱们一起来幽默解读一下这段代码,绝对不会让你看得云里雾里,带你轻松入门! 首先,你看到的这段代码是用Rust写的,Rust可是编程界的硬核选手,但我们今天要用“软萌”的方式讲解它! 1. 企鹅数据,你好!代码一开始,定义了一个叫 let penguin_data = "\
common name,length (cm)
Little penguin,33
Yellow-eyed penguin,65
Fiordland penguin,60
Invalid,data
"; 这就像我们打开了一张表格,第一行是表头,后面跟着的是各类企鹅的“身高数据”。注意, 2. 开始遍历企鹅数据接着,代码用 let records = penguin_data.lines();
for (i, record) in records.enumerate() {
搞笑小插曲:第一行是表头嘛,我们程序员懒得处理这种表头的数据,所以用 if i == 0 || record.trim().len() == 0 {
continue;
} 3. 让数据乖乖“排排坐”接下来最关键的部分,代码把每行数据按逗号 let fields: Vec<_> = record
.split(',')
.map(|field| field.trim())
.collect(); 解说员点评:这样一行数据就变成了一个“字段”列表,比如 if cfg!(debug_assertions) {
eprintln!("debug: {:?} -> {:?}", record, fields);
} 这是为我们这些调皮的开发者准备的“作弊”模式,打开它可以让代码输出每次循环的数据。 4. 把企鹅身高“量”出来然后,这段代码会努力地把第二个字段,也就是企鹅的“身高”,转成浮点数 let name = fields[0];
if let Ok(length) = fields[1].parse::<f32>() {
println!("{}, {}cm", name, length);
} 这里用了个
总结:
|
Beta Was this translation helpful? Give feedback.
-
太爱作者了,让我有兴趣往下读 |
Beta Was this translation helpful? Give feedback.
-
::冒号冒号看着真别扭 |
Beta Was this translation helpful? Give feedback.
-
作者大大太 “rust(指的是:秀)” 了 |
Beta Was this translation helpful? Give feedback.
-
https://course.rs/first-try/hello-world.html
Beta Was this translation helpful? Give feedback.
All reactions