generics-traits/advanced-traits #200
Replies: 55 comments 29 replies
-
`impl<T: Sub<Output = T>> Sub for Point {
}` |
Beta Was this translation helpful? Give feedback.
-
最后一题 为么下面的结果还是11呢 |
Beta Was this translation helpful? Give feedback.
-
请问在第三题里面,为什么不使用完全限定语法也可以编译通过呢? assert_eq!(<Human as Pilot>::fly(&person), "This is your captain speaking.");
assert_eq!(Pilot::fly(&person), "This is your captain speaking.");
assert_eq!(<Human as Wizard>::fly(&person), "Up!");
assert_eq!(Wizard::fly(&person), "Up!"); |
Beta Was this translation helpful? Give feedback.
-
问个问题:第一题我的通过编译的解答是:
但我看参考答案里无论在trait中还是函数签名中都没有给出 std::ops::Sub 的约束,为什么参考答案也能编译通过?下面是参考答案的函数签名:
|
Beta Was this translation helpful? Give feedback.
-
done 我想问一下 |x| x+1这算什么运算? |
Beta Was this translation helpful? Give feedback.
-
done,这章主要讲了泛型与特征的相关知识,目前只能说是有了初步得理解,之后还需通过练习进行更深入得理解 |
Beta Was this translation helpful? Give feedback.
-
第四题没理解 另外减法的时候为什么必须顺序反过来?
···rust struct Foo; #[derive(PartialEq, Debug)] #[derive(PartialEq, Debug)] // The
} impl ops::Sub for Foo {
} fn main() { |
Beta Was this translation helpful? Give feedback.
-
感谢大佬的工作,最近看的rust资料,找了几个不同的教程,这个电子书是最有帮助的,也解答我之前遇到很多的问题。 |
Beta Was this translation helpful? Give feedback.
-
最后一题不理解QAQ |
Beta Was this translation helpful? Give feedback.
-
这个评论跟习题对应不上还是小节里面的归总到一起了?另外 10.5的第四题 &self 签名,为什么不能String::from(self.name), 而是要self.name.clone() |
Beta Was this translation helpful? Give feedback.
-
第8题的 impl<T> Pair<T> {
fn new(x: T, y: T) -> Self {
Self {
x,
y,
}
}
} 似乎有点多余了,下面代码都没用到 |
Beta Was this translation helpful? Give feedback.
-
学到这里 我已经云里雾里了 好难啊 |
Beta Was this translation helpful? Give feedback.
-
破案了,10.3与10.5这两个练习题的评论合在一起了 |
Beta Was this translation helpful? Give feedback.
-
第11题 new的参数 (|x| x+1)是一个闭包,类似于python的lambda函数 |
Beta Was this translation helpful? Give feedback.
-
哎卧槽,把sheep看成了sleep,还以为大神有裸睡习惯。。。 |
Beta Was this translation helpful? Give feedback.
-
mark finished |
Beta Was this translation helpful? Give feedback.
-
mark finished |
Beta Was this translation helpful? Give feedback.
-
This exercise is quite tough could not do most of them , i need revisit again after some more practice of rust |
Beta Was this translation helpful? Give feedback.
-
第4题是不是有点歧义,按题目要求应该是只加派生注解,不改代码。 |
Beta Was this translation helpful? Give feedback.
-
Done ✅ |
Beta Was this translation helpful? Give feedback.
-
generics-traits/advanced-traits
Learning Rust By Practice, narrowing the gap between beginner and skilled-dev with challenging examples, exercises and projects.
https://zh.practice.rs/generics-traits/advanced-traits.html
Beta Was this translation helpful? Give feedback.
All reactions