mirror of
https://github.com/neondatabase/neon.git
synced 2026-05-18 21:50:37 +00:00
error[E0521]: borrowed data escapes outside of method
--> repro-problem/src/virtual_file.rs:702:51
|
692 | impl<'a> FileGuard<'a> {
| -- lifetime `'a` defined here
...
695 | fn with_std_file<F, R>(&mut self, with: F) -> R
| --------- `self` is a reference that is only valid in the method body
...
702 | let mut file = unsafe { File::from_raw_fd(self.as_ref().as_raw_fd()) };
| ^^^^^^^^^^^^^
| |
| `self` escapes the method body here
| argument requires that `'a` must outlive `'static`
|
= note: requirement occurs because of a mutable reference to `FileGuard<'_>`
= note: mutable references are invariant over their type parameter
= help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
12 lines
228 B
Rust
12 lines
228 B
Rust
use virtual_file::VirtualFile;
|
|
|
|
mod virtual_file;
|
|
|
|
#[tokio::main]
|
|
async fn main() {
|
|
let file = VirtualFile::open(camino::Utf8Path::new("foo"))
|
|
.await
|
|
.unwrap();
|
|
file.read_exact_at(vec![0; 8], 0).await;
|
|
}
|