p6s*_*eve 7 rust raku rust-polars
我正在 Rust 中为 Polars 编写一个外部库(供Raku::Dan使用),并且想通过调用 df.lazy() 为 LazyFrame 对象获取一个不透明容器。
use polars::prelude::*;//{CsvReader, DataType, DataFrame, Series};
use polars::prelude::{Result as PolarResult};
use polars_lazy::prelude::*;
// LazyFrame Container
pub struct LazyFrameC {
lf: LazyFrame,
}
impl LazyFrameC {
fn new(ptr: *mut DataFrameC) -> LazyFrameC {
LazyFrameC {
lf: (*ptr).df.lazy(),
}
}
}
// extern functions for LazyFrame Container
#[no_mangle]
pub extern "C" fn lf_new(ptr: *mut DataFrameC) -> *mut LazyFrameC {
let df_c = unsafe {
assert!(!ptr.is_null());
&mut *ptr
};
Box::into_raw(Box::new(LazyFrameC::new(ptr)))
}
Run Code Online (Sandbox Code Playgroud)
不起作用,给出错误:
error[E0599]: no method named `lazy` found for struct `polars::prelude::DataFrame` in the current scope
--> src/lib.rs:549:27
|
549 | lf: (*ptr).df.lazy(),
| ^^^^ method not found in `polars::prelude::DataFrame`
Run Code Online (Sandbox Code Playgroud)
这是我的 Cargo.toml(编辑)...
error[E0599]: no method named `lazy` found for struct `polars::prelude::DataFrame` in the current scope
--> src/lib.rs:549:27
|
549 | lf: (*ptr).df.lazy(),
| ^^^^ method not found in `polars::prelude::DataFrame`
Run Code Online (Sandbox Code Playgroud)
任何有关确定正确库的指导将不胜感激!
小智 4
Dataframe::lazy该功能后面是否标记了lazy功能
尝试将您的cargo.toml从更改
polars = "0.22.1"
为
polars = {version = "0.22.1", features = ["lazy"]}