板条箱找不到路径
Crate cannot find path
我正在尝试使用这个箱子生成一个以太坊地址:https://docs.rs/ethkey/0.2.5/ethkey/
use ethkey::prelude::*;
fn main() {
let key = EthAccount::load_or_generate("~/", "passwd")
.expect("should load or generate new eth key");
println!("{:?}", key.address())
}
这是文档中的示例,它似乎不起作用。
我收到以下错误:
cargo run Compiling ethkey v0.1.0
(/Users/samueldare/Documents/Code/Thor/ethkey)
Finished dev [unoptimized + debuginfo] target(s) in 1.34s
Running target/debug/ethkey
thread 'main' panicked at 'should load or generate new eth key: Error(IoError(Os { code: 2, kind:
NotFound, message: "No such file or directory" }), State { next_error:
None, backtrace: InternalBacktrace { backtrace: None } })',
src/libcore/result.rs:999:5 note: run with RUST_BACKTRACE=1
environment variable to display a backtrace.
我用 ~/
作为最后一次尝试在 Rust 中生成密钥文件,但它似乎仍然不起作用。
如有任何指点,我将不胜感激
load_or_generate()
的第一个参数采用 std::path::Path 且没有右斜线 ('/')。删除斜线:
fn main() {
let key = EthAccount::load_or_generate("~", "passwd")
.expect("should load or generate new eth key");
println!("{:?}", key.address())
}
示例输出:
05:47 ethtest (master) ✗ cargo run
Finished dev [unoptimized + debuginfo] target(s) in 0.04s
Running `target/debug/ethtest`
Address(0x8248af6d1765e559509060b88e540a3567c42d20)
05:47 ethtest (master) ✗
我正在尝试使用这个箱子生成一个以太坊地址:https://docs.rs/ethkey/0.2.5/ethkey/
use ethkey::prelude::*;
fn main() {
let key = EthAccount::load_or_generate("~/", "passwd")
.expect("should load or generate new eth key");
println!("{:?}", key.address())
}
这是文档中的示例,它似乎不起作用。 我收到以下错误:
cargo run Compiling ethkey v0.1.0 (/Users/samueldare/Documents/Code/Thor/ethkey) Finished dev [unoptimized + debuginfo] target(s) in 1.34s Running
target/debug/ethkey
thread 'main' panicked at 'should load or generate new eth key: Error(IoError(Os { code: 2, kind: NotFound, message: "No such file or directory" }), State { next_error: None, backtrace: InternalBacktrace { backtrace: None } })', src/libcore/result.rs:999:5 note: run withRUST_BACKTRACE=1
environment variable to display a backtrace.
我用 ~/
作为最后一次尝试在 Rust 中生成密钥文件,但它似乎仍然不起作用。
如有任何指点,我将不胜感激
load_or_generate()
的第一个参数采用 std::path::Path 且没有右斜线 ('/')。删除斜线:
fn main() {
let key = EthAccount::load_or_generate("~", "passwd")
.expect("should load or generate new eth key");
println!("{:?}", key.address())
}
示例输出:
05:47 ethtest (master) ✗ cargo run
Finished dev [unoptimized + debuginfo] target(s) in 0.04s
Running `target/debug/ethtest`
Address(0x8248af6d1765e559509060b88e540a3567c42d20)
05:47 ethtest (master) ✗