连字符无法识别的板条箱名称
crate name with hyphens not being recognized
我正在尝试使用 exercism
练习 Rust
其中一个问题集有这样的测试文件
当我尝试 运行 货物测试时,它无法识别板条箱 name.I 尝试了不同的方差变化,"difference-of-squares" 但没有成功。
Cargo.toml
的内容
编辑:我尝试了稳定版和当前的 nightly。
您可能使用的是旧版本的 Cargo。以前,crates-with-hyphens 是允许的,但使用起来很糟糕:
extern crate "difference-of-squares" as squares;
在过去的某个时候,Cargo 被更改为基本上不允许它们;它只是将所有连字符转换为下划线,因此您不必在每次使用时手动重命名名称中包含连字符的每个板条箱。
您没有指定您使用的是什么版本,但更新到最新版本(Rust 1.2 刚刚发布 将在几天内发布)应该可以修复它.如果做不到这一点,请尝试引用板条箱的字面名称。
对于最新版本的 Cargo,如果您的 crate 名称带有连字符,您可以直接依赖下划线。 Cargo 实际上给你这个提示:
error: crate name using dashes are not valid in `extern crate` statements
--> tests/config.rs:1:14
|
1 | extern crate my-crate;
| ^^^^^^^^ dash-separated idents are not valid
|
help: if the original crate name uses dashes you need to use underscores in the code
|
1 | extern crate my_crate;
| ~
我正在尝试使用 exercism
练习 Rust其中一个问题集有这样的测试文件
当我尝试 运行 货物测试时,它无法识别板条箱 name.I 尝试了不同的方差变化,"difference-of-squares" 但没有成功。
Cargo.toml
的内容编辑:我尝试了稳定版和当前的 nightly。
您可能使用的是旧版本的 Cargo。以前,crates-with-hyphens 是允许的,但使用起来很糟糕:
extern crate "difference-of-squares" as squares;
在过去的某个时候,Cargo 被更改为基本上不允许它们;它只是将所有连字符转换为下划线,因此您不必在每次使用时手动重命名名称中包含连字符的每个板条箱。
您没有指定您使用的是什么版本,但更新到最新版本(Rust 1.2 刚刚发布 将在几天内发布)应该可以修复它.如果做不到这一点,请尝试引用板条箱的字面名称。
对于最新版本的 Cargo,如果您的 crate 名称带有连字符,您可以直接依赖下划线。 Cargo 实际上给你这个提示:
error: crate name using dashes are not valid in `extern crate` statements
--> tests/config.rs:1:14
|
1 | extern crate my-crate;
| ^^^^^^^^ dash-separated idents are not valid
|
help: if the original crate name uses dashes you need to use underscores in the code
|
1 | extern crate my_crate;
| ~