I have owned and borrowed versions of a struct: the owned one has a Vec field, the borrowed one has a slice field. It looks like Foo<'a> and OwnedFoo. Is there a way to impl Deref here? (The problem is that there is no 'a in Deref).
6
8
My gut feeling is "No because OwnedFoo is not a smart pointer to a Foo" I'd probably lean toward an `impl AsRef<[_]> for OwnedFoo` or else a `pub fn borrow(&self) -> Foo<'_>` Deref requires that the implementing type "contain" the target.
1
1
I woke up this morning to realise I was "preaching Rust" at someone who has done it for much longer than me. Whoopsie :D

Nov 19, 2020 ยท 8:01 AM UTC

1
Replying to @dsilverstone
๐Ÿคฃ