Replies: 43 comments 41 replies
-
辛苦了 这里确实挺黑暗的 |
Beta Was this translation helpful? Give feedback.
-
<'b, 'c> 这个 |
Beta Was this translation helpful? Give feedback.
-
这节突然难度加大,待我先吃个饭晚上再看一遍,作者辛苦了,看得出来这本书写的真的用心。 |
Beta Was this translation helpful? Give feedback.
-
前面的内容还能接受 变形记有点受不了 |
Beta Was this translation helpful? Give feedback.
-
从上面代码可以看出,派生 Clone 能实现的根本是 T 实现了Clone特征:where T: Clone, 因此 Container 就没有实现 Clone 特征。 这句话有点不理解,看上面的代码不是已经实现了clone方法么,为啥说没有实现Clone特征? |
Beta Was this translation helpful? Give feedback.
-
impl<'a> Trait for &'a i32 {} 中的 'a是什么泛型啊?'a难道不可以使mut吗? |
Beta Was this translation helpful? Give feedback.
-
强制类型转换是真心没看懂啊,到底是谁强制转换到了谁,能不能再仔细讲讲。&i32 实现了特征 Trait, &mut i32 可以转换为 &i32,但是 &mut i32 依然无法作为 Trait 来使用。这句话怎么理解。 |
Beta Was this translation helpful? Give feedback.
-
哈哈好难!是因为太难了吗?练习题都没安排~ |
Beta Was this translation helpful? Give feedback.
-
根据我的实验,
关键的地方在于第2步的第(1)步,如果a的类型是&T,其实会先去尝试调用T的方法。 而如果a是其他实现了 |
Beta Was this translation helpful? Give feedback.
-
为什么b的类型改成i32会导致下面无法判断e的类型?
} |
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.
-
喂,前方可是地狱啊 |
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.
-
二刷了,感觉这里居然能看懂了,记得之前看到这一块是一塌糊涂的,也不知道是作者改进表述了还是我真的开悟了。。。 |
Beta Was this translation helpful? Give feedback.
-
”首先也是最重要的,转换后创建一个任意类型的实例会造成无法想象的混乱,而且根本无法预测。不要把 3 转换成 bool 类型,就算你根本不会去使用该 bool 类型,也不要去这样转换。 “ |
Beta Was this translation helpful? Give feedback.
-
我们先来推导一番。 首先通过值方法调用就不再可行,因为 T 没有实现 Clone 特征,也就无法调用 T 的 clone 方法。接着编译器尝试引用方法调用,此时 T 变成 &T,在这种情况下, clone 方法的签名如下: fn clone(&&T) -> &T,接着我们现在对 value 进行了引用。 编译器发现 &T 实现了 Clone 类型(所有的引用类型都可以被复制,因为其实就是复制一份地址),因此可以推出 cloned 也是 &T 类型。 这里的值调用,因为value是&T类型,所以尝试值调用不是直接先从&T开始匹配吗?为什么这里说先看T呢?所谓的值调用,是看当前值的原始类型T?而不是先看当前值的实际类型&T吗?没看明白 |
Beta Was this translation helpful? Give feedback.
-
有些复杂,感觉短暂的未来应该不会用到这么深的知识,以后有需要再来查阅 |
Beta Was this translation helpful? Give feedback.
-
点操作符小节那里:
|
Beta Was this translation helpful? Give feedback.
-
如果之前是写C语言的,特别是写嵌入式裸机程序的。Transmutes里的操作简直是家常便饭,Rust主要还是想给用的人足够的控制力吧。 |
Beta Was this translation helpful? Give feedback.
-
1.75.0版Rust,TryInto 特征是预导入的,不需要use |
Beta Was this translation helpful? Give feedback.
-
fn do_stuff(value: &T) { |
Beta Was this translation helpful? Give feedback.
-
impl<T> Clone for Container<T> where T: Clone {
fn clone(&self) -> Self {
Self(Arc::clone(&self.0))
}
} 这个是在哪里看的?我点进去 |
Beta Was this translation helpful? Give feedback.
-
点操作符那里,好像在引用方法调用和值方法调用之间还有一个::foo(&value)的调用 |
Beta Was this translation helpful? Give feedback.
-
https://course.rs/advance/into-types/converse.html
Beta Was this translation helpful? Give feedback.
All reactions