I have a Rust struct T<'a> with Cow<'a, X> fields. I want to create .to_owned version of the struct and embed in another struct with a different lifetime. Lifetime of new struct could be shorter or longer. How do I do that?
-
-
Oh, I thought the ToOwned trait would conflict if I tried to implement to_owned() on a trait-less impl! I guess it doesn't. Thanks!
-
If you want to use the `ToOwned` trait you should probably create an owned version of your struct with no lifetime instead of `Cow`
- 4 more replies
New conversation -
-
-
Or if you want arbitrary lifetimes instead of `'static`, https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=0eac05cf3a89e49de6a7f4a0423de3fe …
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.