We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
在 rust编程之道书里 有这么一段程序
trait Foo{ fn bad<T>(&self,x:T); fn new()->Self where Self:Sized; }
如果说我们想将一个trait作为trait对象使用,那么我们就必须保证trait中的所有方法都是对象安全的
在前面对象安全中 有一点说到对象安全必须不包含任何泛型参数
但是书上上述代码中 这个trait是对象安全的
请问是我的理解有问题吗?
The text was updated successfully, but these errors were encountered:
不是太明白你的意思,我手里没有编程之道的书,希望你能把原文拍照发上来之类的。
代码最好使用 ``` 来进行格式化
Sorry, something went wrong.
不是太明白你的意思,我手里没有编程之道的书,希望你能把原文拍照发上来之类的。 代码最好使用 ``` 来进行格式化
好的 我订正下
根据The Book所说,你贴的这段程序里刚好违背了对象安全的两个要求。
Self
我前往 Rust 编程之道 的勘误列表,找到了这个 Issue,应该是作者的笔误。 #137 关于trait的Self类型参数不能被限定为Sized
根据The Book所说,你贴的这段程序里刚好违背了对象安全的两个要求。 The return type isn’t Self. There are no generic type parameters. 我前往 Rust 编程之道 的勘误列表,找到了这个 Issue,应该是作者的笔误。 #137 关于trait的Self类型参数不能被限定为Sized
好的 谢谢你! 勘误列表已收藏
No branches or pull requests
在 rust编程之道书里 有这么一段程序
如果说我们想将一个trait作为trait对象使用,那么我们就必须保证trait中的所有方法都是对象安全的
在前面对象安全中 有一点说到对象安全必须不包含任何泛型参数
但是书上上述代码中 这个trait是对象安全的
请问是我的理解有问题吗?
The text was updated successfully, but these errors were encountered: