rust-cargo

Cannot use the `doc!` macro from the mongodb crate in the scope of a sub sub module

南笙酒味 提交于 2019-12-23 03:14:18
问题 I use following file structure: ├── src │ ├── main.rs // Macros from here │ ├── models │ │ ├── mod.rs // Loads the user.rs file │ │ └── user.rs // Should be visible here ├── Cargo.toml My main.rs file imports the stuff like: #[macro_use] extern crate mongodb; mod models; My user.rs file looks like: pub struct User { username: String, password: String, } impl User { fn create_doc() { // Some code, but doc! from crate mongodb is not in this scope. } } How can I use my doc! macro in the user.rs

Unable to override Rustup toolchain for custom build of iOS Toolchain

倾然丶 夕夏残阳落幕 提交于 2019-12-22 10:11:04
问题 I am creating my own toolchain with my build of Rust. I need this to cross compile with iOS architectures. When trying to set the default toolchain or override the current directory's toolchain, I'm getting an error regarding the name of my toolchain. These are the steps I took to create this new toolchain: Create Rustup Toolchain rustup toolchain link ios $HOME/rustc-ios Override current directory toolchain rustup override set ios $ rustup show Default host: x86_64-apple-darwin error:

How to generate documentation for private items

痞子三分冷 提交于 2019-12-22 05:14:50
问题 I have a project with: main.rs module_1/mod.rs module_2/mod.rs module_2/module_3/mod.rs when I run cargo doc , I have just documentation for main.rs , not for modules. In my main.rs I have: mod module_1; mod module_2; fn main() { ... } I have tried documenting modules using /// or //! . I can't find in rustdoc 's help how do that. Somebody can explain me? 回答1: This is because those modules are private, and the default behavior is to document public members only. As of Rust 1.29.0, cargo doc

How can I set default build target for Cargo?

风格不统一 提交于 2019-12-22 04:29:26
问题 I tried to make 'Hello World' in Rust using this tutorial, but the build command is a bit verbose: cargo +nightly build --target wasm32-unknown-unknown --release Is it possible to set the default target for cargo build ? 回答1: I guess you could use a cargo configuration file to specify a default target-tripple for you project: https://doc.rust-lang.org/cargo/reference/config.html In you project's root create a .cargo directory and a config file in it with the following contents: [build] target

Copy files to the target directory after build

寵の児 提交于 2019-12-22 03:54:35
问题 Let's assume I have a game with the following directory structure: /src /resources Cargo.toml I would like cargo build to copy the files in the resources directory and paste them in the same directory as the executable file. I know it is possible to do this using a custom build script, but this seems to be a common case that deserves special treatment. So the question is: does cargo provide a standard way of copying files to the target directory (using just Cargo.toml )? 回答1: No, it doesn't.

Consolidating cargo dependencies

做~自己de王妃 提交于 2019-12-22 03:19:30
问题 I have a project that has a dependency (a cookie utility) that has a dependency on iron >= 0.3, <= 0.4 . My project has a dependency on iron 0.3 (so I can use the router middleware that hasn't yet been updated to the latest iron). When I try to compile my project, the cookie utility pulls the 0.4 version of iron, and I get errors since different versions of iron are being used. However, I can do: cargo update -p <cookie utility> which (usually) changes that package's dependency on iron to

What is the syntax for specifying dependency versions in Cargo?

拟墨画扇 提交于 2019-12-21 07:00:25
问题 So far I have seen three... [dependencies] crate = "1.0.0" # I think this is an exact version match crate = "^1.0.0" # I think this means "use that latest 1.x.x" crate = "*" # I think this means "use the latest" I'd love to know for certain how to use the dependency list. It would be nice to have an authoritative source that documents the different syntaxes for dependencies. 回答1: See the crates.io documentation page on "Specifying Dependencies". To summarise: Nothing or a caret ( ^ ) means

How to launch a Rust application from Visual Studio Code?

六月ゝ 毕业季﹏ 提交于 2019-12-20 10:31:33
问题 I have installed the Visual Studio Code extensions for Rust: I want to run my project and I don't understand where to click. I tried clicking Run Task , Run build task , Configure Default build task , but nothing reasonable happens. 回答1: Using the integrated terminal Shortcut to run the integrated terminal: Ctrl + ` (Ctrl + backtick) Run the following command in the integrated terminal: cargo run Notes: Open the Code editor from your project folder ( code . command inside project folder

error[E0554]: #![feature] may not be used on the stable release channel Couldn't install racer using cargo

放肆的年华 提交于 2019-12-20 10:24:39
问题 I'm trying to install racer using cargo, so I executed the command cargo install racer in the terminal and it resulted in the error: error[E0554]: #![feature] may not be used on the stable release channel --> /home/rajkumar/.cargo/registry/src/github.com-1ecc6299db9ec823/scoped-tls-0.1.2/src/lib.rs:47:34 | 47 | #![cfg_attr(feature = "nightly", feature(macro_vis_matcher))] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0554]: #![feature] may not be used on the stable release channel --> /home/rajkumar/

Could not exec the linker `cc` error when running “cargo build”

青春壹個敷衍的年華 提交于 2019-12-19 15:47:02
问题 I just installed Rust on my Mac and rustc --version --verbose displays rustc 1.0.0-nightly (91bdf23f5 2015-03-09) (built 2015-03-08) binary: rustc commit-hash: 91bdf23f504f79ed59617cde3dfebd3d5e39a476 commit-date: 2015-03-09 build-date: 2015-03-08 host: x86_64-apple-darwin release: 1.0.0-nightly I cloned a couple of repositories (postgres-extension and erlang-rust-nif) and ran cargo build upon both of them. Both reported the error error: could not exec the linker `cc`: No such file or