extend the lifetime of borrowed resource get#1406
extend the lifetime of borrowed resource get#1406alexcrichton merged 6 commits intobytecodealliance:mainfrom
get#1406Conversation
|
Thanks! For this I'd prefer to have one of (a) leave them private and users use the |
resource::as_ptr publicget
|
I have a better fix now. The original |
alexcrichton
left a comment
There was a problem hiding this comment.
Looks good to me! I had to re-convince myself this is safe as well but I believe it is.
Mind adding a test for this too?
The original get function elides the lifetime, so we have
fn get(&'b self) -> &'b T. But sinceBorrow<'a>is valid for the whole'aduration, we should be able to borrow&'a Tinstead. The new signature is also semantically more accurate.