I’m stating the obvious here, but if you have ownership at the time of conversion, then you can just change the type, you don’t have to use dyn (a la impl Foo<false> { fn into_debug(self) -> Foo<true> {} }
). That may require some code restructuring of course.
Yes… if you don’t define
Drop
forFoo
.If you do, then you will have to either use
mem::take()
/mem::replace()
with each field, or if you don’t mindunsafe {}
, you can just do a trivial transmute. Justunsafe { transmute(self) }
should work.