如何使用Cargo运行项目的示例?

时间:2019-01-31 21:25:04

标签: rust rust-cargo

我正在尝试运行示例代码from this project。按照货运文档上的说明,我执行了以下操作:

git clone https://github.com/basiliscos/rust-procol-ftp-client
cd rust-procol-ftp-client
cargo run 
cargo test

cargo test还应该根据Rust文档编译the example

尽管cargo test执行成功,但是当我切换到target/debug目录时,找不到ftp-get的可执行文件(这是示例代码)。 target/debug/examples目录也为空。

运行此示例的最佳方法是什么?

2 个答案:

答案 0 :(得分:4)

您可以运行以下示例:

cargo run --example name_of_example

或在发布模式下运行它:

cargo run --release --example name_of_example

将参数传递给示例:

cargo run --example name_of_example -- arguments go here

cargo run如果过期,将首先自动构建(或重建)程序。

答案 1 :(得分:3)

尝试以下操作:

curl https://packages.microsoft.com/config/ubuntu/18.04/prod.list > /etc/apt/sources.list.d/mssql-release.list
sudo apt-get update
sudo ACCEPT_EULA=Y apt-get install msodbcsql17