Post #3613081
2025-12-29 18:22 UTC
Replies (1)
-
@zwarich@hachyderm.io 2025-12-29 19:33
@joe@f.duriansoftware.com @foonathan@fosstodon.org @dotstdy@mastodon.social @ianh@mastodon.social I think most languages that would allow you to return borrows would let you also store them as struct fields, etc. and just add a borrowed pointer type, in which case you could just make a tuple of borrows. I guess you could take a purist "parameter modes" approach and define borrowed struct fields via parameter modes on the struct's constructor? However, I think it might be tricky to make this work well with generics. Another place where a similar distinction comes up is in-place construction of return values. Rust doesn't have this, but I assume that some successor language will want this to support internal self-reference, e.g. for efficient containers with inline capacity