生锈错误[E0597]:寿命不够长

问题描述 投票:0回答:1

我正在尝试简化 this Nodejs-Polars 代码。
我有

path_or_buffer: Either<String, Buffer>
作为函数参数。 尝试匹配时:

let file = match path_or_buffer {
   Either::A(path) => Box::new(std::fs::File::open(path).unwrap()) as Box<dyn MmapBytesReader>,
   Either::B(buffer) => Box::new(Cursor::new(buffer.as_ref())) as Box<dyn MmapBytesReader>
}

我得到:

error[E0597]: buffer does not live long enough
谢谢

rust nodejs-polars
1个回答
0
投票

是我在GH中的解决方案。谢谢大家!

© www.soinside.com 2019 - 2024. All rights reserved.