rust-cargo

How can I include private modules when generating documentation via Cargo?

亡梦爱人 提交于 2020-01-21 04:13:05
问题 I'm currently working on a project with Rust and Cargo. It works well, but I encounter a little issue: for code reuse, most of my project is inside a lib crate. In this crate, a lot of things is private. So when I do cargo doc , I just have documentation for public, exported stuff... which is actually great, because it's easy to see what is exported and what is not. But I have to admit: I miss a complete documentation of the whole project, for development purpose... 回答1: This can be done by

Linking AVR programs with Cargo

懵懂的女人 提交于 2020-01-17 07:18:22
问题 I have a Rust project which I am currently compiling and linking by hand: rustc --target=avr-atmel-none src/main.rs --emit=obj -o _build/main.rs.o -C opt-level=3 avr-gcc -Os -Wl,--gc-sections -mmcu=atmega328p -o _build/image.elf _build/main.rs.o avr-objcopy -Oihex -R.eeprom _build/image.elf _build/image.hex I would like to automate this with Cargo, so I started by setting avr-gcc as the linker, by adding the following to .cargo/config : [build] target = "avr-atmel-none" [target.avr-atmel-none

OpenSSL crate fails compilation on Mac OS X 10.11

梦想与她 提交于 2020-01-17 03:07:50
问题 I tried to install the Iron framework for Rust on Mac OS X 10.11.2, but it failed when I run cargo build or cargo run on compiling openssl 's stuff: failed to run custom build command for `openssl-sys-extras v0.7.4` Process didn't exit successfully: `/xxx/rust/hello/target/debug/build/openssl-sys-extras-413d6c73b37a590d/build-script-build` (exit code: 101) --- stdout TARGET = Some("x86_64-apple-darwin") OPT_LEVEL = Some("0") PROFILE = Some("debug") TARGET = Some("x86_64-apple-darwin") debug

How do I access files in the src directory from files in my tests directory?

懵懂的女人 提交于 2020-01-15 08:59:21
问题 I have a project layout that looks like the following: src/ int_rle.rs lib.rs tests/ test_int_rle.rs The project compiles with cargo build , but I am unable to run the test with cargo test . I get the error error[E0432]: unresolved import `int_rle`. There is no `int_rle` in the crate root --> tests/test_int_rle.rs:1:5 | 1 | use int_rle; | ^^^^^^^ error[E0433]: failed to resolve. Use of undeclared type or module `int_rle` --> tests/test_int_rle.rs:7:9 | 7 | int_rle::IntRle { values: vec![1, 2,

Is it documented that Cargo can download and bundle multiple versions of the same crate?

落花浮王杯 提交于 2020-01-13 16:22:10
问题 By forking and playing with some code, I noticed that Cargo can download and bundle multiple versions of the same crate in the same project (native-tls 0.1.5 and 0.2.1, for example). I have wasted so much time by looking at the documentation of the wrong version. I have looked for some information about this behaviour but I was not able to find anything. Is this documented somewhere? Is there an easy way to determine/detect the version used by the code you're working on (current edited file)?

How do I access assets included in a Rust/Cargo project installed via `cargo install`?

淺唱寂寞╮ 提交于 2020-01-13 08:00:48
问题 I have a project which includes some associated assets (Lua scripts), which I need to find at runtime. This can mean two things: During development (e.g. cargo run ), I want to find it relative to the source When installed via cargo install , the assets should be installed somewhere as well, and the installed version of the executable should find the installed assets. I know about the option to use something like include_str!() to compile text files into the binary, but I don't want to do

How do I run a project's example using Cargo?

心已入冬 提交于 2020-01-11 10:23:12
问题 I'm trying to run the example code from this project. Following the instructions on the Cargo docs, I did the following: git clone https://github.com/basiliscos/rust-procol-ftp-client cd rust-procol-ftp-client cargo run cargo test cargo test should also have compiled the example according to the Rust docs. Although cargo test executes successfully, when I change into the target/debug directory, I don't find an executable for ftp-get (which is the example code). The target/debug/examples

How do I use a specific edition of Rust?

淺唱寂寞╮ 提交于 2020-01-11 09:17:09
问题 I know there are currently two editions of Rust ( 2015 and 2018 ), how can I tell cargo and rustc which one I want to use? 回答1: You can add the following to your Cargo.toml , it's documented on the edition 2018 guide: [package] edition = "2018" If you directly use rustc you can use rustc --edition 2018 , it's documented with rustc --help -v command. --edition 2015|2018 Specify which edition of the compiler to use when compiling code. 来源: https://stackoverflow.com/questions/55504416/how-do-i

Is it possible to deactivate file locking in cargo?

天涯浪子 提交于 2020-01-11 09:07:25
问题 I want to run the following commands side by side cargo watch "check" cargo watch "build" I want to run cargo watch build in the background and use cargo watch check to look at the error messages. The problem is that cargo watch check always runs after cargo watch build and then also needs to wait on the file lock cargo check Blocking waiting for file lock on build directory I don't think that a file lock would be required for cargo check. Is it possible to disable file locking in cargo? 回答1:

Is it possible to deactivate file locking in cargo?

前提是你 提交于 2020-01-11 09:05:32
问题 I want to run the following commands side by side cargo watch "check" cargo watch "build" I want to run cargo watch build in the background and use cargo watch check to look at the error messages. The problem is that cargo watch check always runs after cargo watch build and then also needs to wait on the file lock cargo check Blocking waiting for file lock on build directory I don't think that a file lock would be required for cargo check. Is it possible to disable file locking in cargo? 回答1: