book
book copied to clipboard
Chapter 19.1 unclear unsafe traits
- [x] I have checked the latest
mainbranch to see if this has already been fixed - [x] I have searched existing issues and pull requests for duplicates
URL to the section(s) of the book with this problem: https://github.com/rust-lang/book/blob/main/src/ch19-01-unsafe-rust.md#implementing-an-unsafe-trait
Description of the problem: Quote from the book: A trait is unsafe when at least one of its methods has some invariant that the compiler can't verify. But through testing, I found that the following code can be compiled:
unsafe trait SomeTrait {
fn some_fn();
}
unsafe trait SomeTrait {}
I also consulted the following information: https://users.rust-lang.org/t/what-is-unsafe-trait/64225/4 In my opinion, there should be no relationship between whether trait is insecure or not and whether the method of trait is insecure or not.
Suggested fix: If I am right, please remove this passage from the book: A trait is unsafe when at least one of its methods has some invariant that the compiler can't verify.