Error installing a crate via cargo: specified package has no binaries

cargo install is used to install binary packages that happen to be distributed through crates.io. If you want to use a crate as a dependency, add it to your Cargo.toml. Read the Rust getting started guide and the Cargo getting started guide for further information. In short: cargo new my_project cd my_project echo ‘curl = … Read more

How can I locate resources for testing with Cargo?

The environment variable CARGO_MANIFEST_DIR can give you a stable base point to reference other files. Here, we assume that there’s a resources/test directory at the top level of the crate: use std::path::PathBuf; fn main() { let mut d = PathBuf::from(env!(“CARGO_MANIFEST_DIR”)); d.push(“resources/test”); println!(“{}”, d.display()); } See also: How can a Rust program access metadata from its … Read more

How to opt out of running a doc test?

This is documented in The rustdoc book, specifically the chapter about attributes. Your opening codeblock delimiter should look like: /// “`no_run From the book: /// “`no_run /// loop { /// println!(“Hello, world”); /// } /// “` The no_run attribute will compile your code, but not run it. This is important for examples such as “Here’s … Read more

How to include files from same directory in a module using Cargo/Rust?

All of your top level module declarations should go in main.rs, like so: mod mod1; mod mod2; fn main() { println!(“Hello, world!”); mod1::mod1fn(); } You can then use crate::mod2 inside mod1: use crate::mod2; pub fn mod1fn() { println!(“1”); mod2::mod2fn(); } I’d recommend reading the chapter on modules in the new version of the Rust book … Read more

How to launch a Rust application from Visual Studio Code?

Using the integrated terminal Run the following command in the integrated terminal: cargo run TLDR: Install rust-analyzer and Native debugger based on LLDB extensions, then use the Run menu (then see the terminal for the result/output): You may install these extensions using the terminal commands (and then restart the vscode): # apt install musl lldb … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)