We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
impl
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
I think this is an omission from TRPL, in the description of either Lifetimes or impl - requesting because I think any new user would benefit from it.
Having got a limited understanding of struct, lifetime and impl I wanted to write
struct
pub struct Foo<'a> { ... } impl Foo<'a> { pub fn new<'a>(...) -> Foo<'a> { ...} }
thinking that the 'a on impl Foo defines it for... whatever is using it later.
'a
impl Foo
I got the answer (thanks user22207 / made mcast/markdown-chapterise@9fcff539) and concluded that in
impl<'a> Foo<'b> { // does not compile
I am defining 'a for the impl block, then using that definition at 'b (which must be 'a here, to compile) to describe the Foo.
'b
Foo
The sort of explanatory example that would make sense to me would be like
// does not compile struct Foo<'a, 'b> { bar: &'c str, baz: &'d str, } impl<'e, 'f> Foo<'g, 'h> { fn mkfoo<'i>(arg: &'j str) -> Foo<'k> { ... } }
in which I avoid repeating a lifetime label so it's easier to describe
'a == 'c == 'e
The text was updated successfully, but these errors were encountered:
Describe lifetime syntax for impl
f29b565
Fixes rust-lang#26375
Rollup merge of rust-lang#26852 - steveklabnik:gh26375, r=alexcrichton
a97687e
No branches or pull requests
I think this is an omission from TRPL, in the description of either Lifetimes or impl - requesting because I think any new user would benefit from it.
Having got a limited understanding of
struct
, lifetime andimpl
I wanted to writethinking that the
'a
onimpl Foo
defines it for... whatever is using it later.I got the answer (thanks user22207 / made mcast/markdown-chapterise@9fcff539) and concluded that in
I am defining
'a
for the impl block, then using that definition at'b
(which must be'a
here, to compile) to describe theFoo
.The sort of explanatory example that would make sense to me would be like
in which I avoid repeating a lifetime label so it's easier to describe
'a == 'c == 'e
and so on, to make it compileThe text was updated successfully, but these errors were encountered: