-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
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
Returned lifetimes are too restrictive. #1
Comments
Updated |
You have pointed out that the It seems like your solution for this problem requires the Rust "arbitrary_self_types" feature, hopefully this will be stabilized in Rust 1.86 (I'm not sure): rust-lang/rust#135881 |
yep! I actually didn't realize it also affects the main branch. Maybe the same fix (make |
i've merged Not sure whether to wait until arbitrary_self_types is stable for a release or what |
If you call a method on a
Local<'env, Foo>
, it gets borrowed for a new shorter lifetime'short
, and deref'd to&'short Foo
. The method then returns aLocal<'short, Bar>
.This is unnecessarily restrictive, it could return a
Local<'env, Bar>
, ReturningLocal<'short, Bar>
is annoying, for example it prevents moving or destroying the originalFoo
while theBar
is live.I have prototyped a possible solution using arbitrary self types. Methods take
self: Ref<'env, Self>
instead of&self
, so they can "see" the original'env
lifetime and returnLocal<'env>
. Seems it works nicely so far. See branch: https://github.com/Dirbaio/java-spaghetti/tree/receiverThere's a newer RFC for arbitrary self types v2, hopefully there's a push to stabilize it soon. rust-lang/rfcs#3519
I don't know if there's a reasonably ergonomic way of solving this without arbitrary self types. Solutions are welcome.
The text was updated successfully, but these errors were encountered: