Closed davidatsurge closed 1 month ago
yeah, you're right.
be careful about making assumptions about methods which take/return self
tho, because self
could contain refs, and those refs lifetimes would be elided, e.g.
struct Struct<'a> {
s: &'a str,
}
impl Struct<'_> {
// looks pretty innocent, no lifetimes or references in sight
fn method(self) -> Self {
self
}
}
desugars to:
struct Struct<'a> {
s: &'a str,
}
impl<'a> Struct<'a> {
fn method(self: Struct<'a>) -> Struct<'a> {
self
}
}
but anyway, i updated the wording in the article in this commit, thanks for making this issue
The list of common misconceptions contains:
But that's not always true right?