Replies: 1 comment 1 reply
-
In the code you linked, you've introduced a generic parameter (confusingly) called impl Point<u32> {
fn y(&self) -> &u32 {
&self.1
}
} which works as expected. Note also the tell-tale compiler warning from your original version:
|
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
In https://google.github.io/comprehensive-rust/generics/methods.html, the speaker notes say
However, if I write an impl for u32 it works for an f32 Point also. Playground link - https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=92385be6813b562a9e8f99542e73ef5d
What am I missing here?
Beta Was this translation helpful? Give feedback.
All reactions