Casting a borrowed reference with a lifetime to a raw pointer in Rust
问题 I am new to rust and am trying to wrap my head around lifetimes. Please consider the following code: use jni::JNIEnv; pub struct CameraAppEngine<'a> { _env: &'a JNIEnv<'a>, _width: i32, _height: i32 } impl<'a> CameraAppEngine<'a> { pub fn new(_env: &'a JNIEnv<'a>, _width: i32, _height: i32) -> CameraAppEngine { CameraAppEngine { _env, _width, _height } } pub fn env(&'a self) -> JNIEnv<'a> { JNIEnv::from_raw(self._env).unwrap() // error! } } The JNIEnv::from_raw method has a type signature of