这是以前从来没有出现过的问题,在我添加Excel功能后突然出现
use crate::common::offic::excel; // <<--
use clap::Parser;
use jni::objects::*;
use jni::JNIEnv;
use std::path::Path;
use HspiceCompiler::hspice::spice; // <<--
#[derive(Parser, Debug)]
#[command(author, version, about)]
pub struct Args {
#[clap(help = "Hspice file name")]
pub file_name: String,
#[clap(short, long)]
pub output_path: String,
}
fn main() {
let args = Args::parse();
let spice_file = Path::new(&args.file_name);
let output_path = Path::new(&args.output_path);
loading(args);
spice_file.try_exists().expect("Can't access hspice file");
let mut reader = spice::Reader::new();
let data_iter = reader.read(spice_file);
reader.analysis_iter(data_iter);
excel::write_to_excel(data_iter, output_path);
}
fn loading(args: Args) {
...
}
字符串
错误代码:
error[E0433]: failed to resolve: could not find `common` in the crate root
--> src/bin/run.rs:1:12
|
1 | use crate::common::offic::excel;
| ^^^^^^ could not find `common` in the crate root
error[E0433]: failed to resolve: use of undeclared type `HspiceCompiler`
--> src/bin/run.rs:5:5
|
5 | use HspiceCompiler::common::offic::excel;
| ^^^^^^^^^^^^^^ use of undeclared type `HspiceCompiler`
型
我的github -> run.rs:https://github.com/llllishuo/menghan_Hspice_Compiler/blob/main/src/bin/run.rs
1条答案
按热度按时间qvk1mo1f1#
crate
引用crate的根模块,在本例中为 *src/bin/run.rs *。如果您想引用同一个包中的库crate,则需要通过包的名称来引用它。字符串
但是,您的包目前没有rust库,因为您的Cargo.toml只包含一个dynamic system library:
型
如果你想把这个库也用作rust库,你还应该包含
lib
。型
这也会纠正你的第二个错误。