Thank you for your response and the idea with the monomorphization check. I'm not sure if mem::transmute_copy(&*mem::ManuallyDrop::new(src))
would be zero-cost though?
For me, the best solution probably is to not use transmute
and instead (implicitly) pass a lifetime to get_unsafe
as in my last code block.
Interestingly, I wasn't able to pass the lifetime explicitly to get_unsafe
:
warning: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present
--> src/lib.rs:914:42
|
861 | &mut self,
| - the late bound lifetime parameter is introduced here
...
914 | unsafe { Ok(backend.get_unsafe::<'b, _, K, V>(self.env, db, key)?) }
| ^^
|
= note: `#[warn(late_bound_lifetime_arguments)]` on by default
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #42868 <https://github.com/rust-lang/rust/issues/42868>
But if I omit the 'b
from the turbofish it works fine.
Now I totally forgot again what late-boundedness was. It had to do something with passing lifetimes explicitly. What was this rhyme again? … Late bound, un-sound, spinning around…
No, it was: