Questions tagged [rust-cargo]
Cargo is the official package manager for the Rust programming language.
1,580
questions
-1
votes
0
answers
30
views
rust workspaces: how build a .dll to be used as separate file instead of be included in the exe?
Why this question is NOT duplicated
Pointed question is all about problem raised in my first solution (cannot satisfy dependency)
But my actual question is totally different! I am here to ask how to ...
0
votes
0
answers
37
views
cargo install racer - compiler errors
I'm trying to install racer using cargo install:
cargo +nightly install racer
And at some point it fails with these errors:
Compiling racer v2.2.2
error[E0053]: method `fallback_fluent_bundle` has ...
0
votes
2
answers
59
views
rust implement trait for multiple types
I am trying to implement a traits for multiple types at once, the only way I found to avoid code duplication is to transform all types to one common struct and implement the trait for that struct as ...
-1
votes
1
answer
48
views
How do i convert and calculate a string expression into arithmetic expression without external crate?
How do i convert and calculate a string expression into arithmetic expression without external crate
for example: “500+10-66*32”. expected result = 14208 (Do not want the precedence of operator)
//a ...
0
votes
1
answer
42
views
returns a value referencing data owned by the current function [1]
Error:
I'm still new to rust, and I don't know how to create a copy from refs, or transfer ownership.
Code details:
let result = check_email(&input).await;
let myresult = result.first().unwrap();
...
0
votes
0
answers
132
views
rust-gpu how to use as a dependency?
I am trying to integrate rust-gpu into a project. The docs explain how to use it as a build dependency but the examples use it as a straight dependency, I have struggled with both but I would prefer ...
-3
votes
0
answers
51
views
How to encode and decode a file from the .exe extension in rust language [closed]
This is the code I encrypted, then I write the cipher to a file, then decrypt it from the file, the file is written and read from but it produces a corrupt .exe file.
use std::{fs, io};
use std::fs::{...
1
vote
1
answer
19
views
Referencing crate data types and functions from build script
I have a rust binary crate (well, it also has a lib.rs file for tests), and am trying to write a build script. This build script needs to generate a JSON file from a static rust object (custom struct ...
0
votes
2
answers
46
views
How to deploy custom candy machine program
I was trying to deploy my own modified version of Metaplex's NFT Candy machine on Devnet from "https://github.com/metaplex-foundation/metaplex-program-library/tree/master/candy-machine/program&...
-1
votes
0
answers
51
views
Error: ~/.cargo/bin/cargo: No such file or directory with cargo build after deleting ~/.cargo
After I rm -rf ~/.cargo, cargo build isn't working anymore.
Both cargo and rust are installed.
$ cargo cache -a
-bash: ~/.cargo/bin/cargo: No such file or directory
$ rustup update
-bash: ~/.cargo/...
0
votes
0
answers
24
views
How to resolve a "cyclic package dependency" error?
I've built a minimal app.
[package]
name = "tmp"
version = "0.1.0"
edition = "2021"
[dependencies]
core-foundation = { version = "0.9", features = ["with-...
-1
votes
1
answer
52
views
Rust Polars feature select in Cargo.toml not working
I have a strange behavior. Apparently I must have messed up something:
My toml file:
[package]
name = "test"
version = "0.1.0"
edition = "2021"
[dependencies]
# Version ...
-2
votes
0
answers
41
views
expected enum `main::Option`, found enum `std::option::Option [closed]
This is the code
let num: Option<u32> = None;
match num {
Some(n) => println!("{}", n),
None => println!("No value!"),
}
But it returns:
I'm new to Rust and ...
-3
votes
0
answers
50
views
How do i fix compile error in Rust-Cargo? [closed]
i am trying to compile and run a program that someone else made, there is basically no documentation and I am not familiar with rust at all. Here are the errors i get in the terminal:
error[E0432]: ...
1
vote
1
answer
40
views
How can I run cargo check/test individually on each feature of my Cargo.toml?
Cargo features allow conditional compilation, so the final build will have just specific groups of features which can be filtered by the final user.
Now depending on the complexity of a library crate, ...
-2
votes
1
answer
49
views
Cargo recompiles all dependencies
I think the reason is rust-analyzer extension in VS Code. It does cargo check after saving. And it checks my dependencies too, what is stupid. If i turn it off cargo will build correctly. How can i ...
2
votes
0
answers
14
views
Fail to install gmp-mpfr-sys crate through cargo on mac OS
I had a hard time to install gmp-mpfr-sys. I am using Catalina 10.15.7. Is this Rust crate installable on mac at all?
It looks like some test-suits of gmp caused segmentation fault.
Cargo.toml:
[...
0
votes
1
answer
41
views
error: Working with pcap crate in rust on Windows
I have a linking problem in Rust.
I'm new to rust and I'm building a library project using the pcap crate.
On linux and Mac OS everything works fine, but as soon as I try on Windows I get linking ...
2
votes
1
answer
34
views
Is there a way to split Trait implementation and defenition across different modules?
I'd like to define a trait with many methods:
pub trait DataSetT{
fn numeric_op_1(&self){...};
fn numeric_op_2(&self)->f64{...};
...
fn io_op_1(&self) {..};
fn ...
0
votes
0
answers
44
views
Rust build error: failed to run custom build command for `glib-sys v0.8.0`
I am trying to build a Rust program on Windows 10. When trying to compile a Rust file with I keep getting the following error messages.
cargo run
Compiling glib-sys v0.8.0
Compiling const_fn v0....
0
votes
2
answers
52
views
How to catch a panic without closing the program
I need to catch a panic while the program is running and without closing the program. For example, how to catch a panic here and print “Hello, World”?:
fn main() {
let v = vec![1, 2, 3];
v[99]...
0
votes
1
answer
37
views
Creating Instances From Other Instances With Struct
struct User {
active: bool,
username: String,
email: String,
sign_in_count: u64,
}
fn main() {
let mut user1 = User {
active: true,
username: String::from("...
1
vote
1
answer
70
views
How to remove quotes from the value of a variable in rust
I need to remove the quotes from the value of the variable, so that a variable of a different type is obtained.
From this:
let mut first_variable = "[67, 43, 26, 72]";
Into this:
let mut ...
0
votes
1
answer
31
views
executing method on variable pointer moves the variable itself?
I'm using the rusqlite crate and am doing some queries, basically i'm just trying to check the length of the query results before trying to proceed, however I'm running into error[E0382]: use of moved ...
0
votes
0
answers
23
views
Weird issue with copypasta rust crate whilst setting clipboard context ( .set_contents )
I'm using the copypasta rust crate which is fork from the rust-clipboard library for reading and writing into my clipboard. (I'm on Ubuntu 22 using the X11 clipboard, but this library supposedly ...
0
votes
0
answers
17
views
Run backend for Gnosis Safe Services
I am trying to run backend for Safe services setup. I understand the flow from this document https://docs.gnosis-safe.io/backend/service-architecture. All the services works separately fine but I am ...
-1
votes
0
answers
39
views
I need to decrypt the image by reading the encoder from a file
I have encrypted an image and stored the cipher in a file, because of the length of the text, I read the cipher from the file and the decryption did not work, is the storage in a file correct or not? ...
0
votes
1
answer
55
views
Rust: linking with `x86_64-w64-mingw32-gcc` failed
I'm having a problem when compiling using cargo build/run that seems to happen if i have Strings or Vecs (possibly other things too) in the code.
for example, this works just fine:
fn main() {
let ...
0
votes
1
answer
20
views
Problems installing Inari library
I am new to Rust, so this could be a stupid mistake, but I can't figure out how to fix it.
The problem
I tried to install Inari (a Rust implementation of interval arithmetic, https://crates.io/crates/...
0
votes
1
answer
29
views
Enable chrono feature with r2d2_postgres crate
I'm learning Rust, and I can't seem to use the FromSql trait from the r2d2_postgres crate.
Based on this recommendation, I tried adding the feature in my TOML file:
r2d2_postgres = {version = "0....
0
votes
1
answer
51
views
How to update data stored in Registry
I had a problem modifying the data in the Registry Editor, and I tried to modify it, but I couldn't, please help
extern crate winreg;
use std::io;
use std::path::Path;
use winreg::enums::*
use winreg::...
1
vote
0
answers
37
views
Generating an additional artifact when crate is used as a dependency
I don't know if the title is phrased very well but I'll try my best to explain what I'm trying to achieve.
I have a project consisting of two crates, main-program and patch, the goal of the program is ...
1
vote
1
answer
95
views
How do I solve "error: no matching package named `` found"
Goal: Fix the following error, and have my chain.rs file to be able to access the functions in the crypto.rs file.
crypto is a file in my project I created, not a external crate that can be found on ...
0
votes
0
answers
48
views
Why is `cargo build` not creating a target folder?
I'm running cargo build --release --target wasm32-unknown-unknown which, according to this:
https://bfnightly.bracketproductions.com/webbuild.html#step-1-compile-the-program-for-wasm
should create ...
0
votes
0
answers
28
views
How to get default Cargo output directory to match target architecture?
I'd like the build output directory to follow the architecture I'm building on.
Currently when I use "Cargo build" without any target it puts the output in ./target/debug or ./target/release....
0
votes
1
answer
44
views
Take a screenshot of more than one screen connected to the same device in rust language
I got this code but it takes a screenshot of each screen separately, and I need to take the two screens together .
use screenshots::Screen;
use std::fs;
use std::fs::File;
use std::fmt::Display;
fn ...
0
votes
0
answers
60
views
What does `cargo:backends` mean in build.rs?
The package gtk3-rs has this line on build.rs:
if let Ok(targets) = pkg_config::get_variable(PKG_CONFIG_PACKAGE, "targets") {
println!("cargo:backends={}", targets);
...
1
vote
1
answer
70
views
I can't run the executable of a game made with Bevy
I was following a bevy tutorial and I thought:
What if I run the executable? After all, I will want to share my games in the future.
When i ran the executable, it said that cannot find 2 dlls, ...
0
votes
0
answers
46
views
rust / cargo workspace: how to specify different profile for different sub project
I have a rust Cargo workspace that contains different subproject:
./
├─Cargo.toml
├─project1/
│ ├─Cargo.toml
│ ├─src/
├─project2/
│ ├─Cargo.toml
│ ├─src/
I would like to build one project optimized ...
0
votes
0
answers
50
views
Why can't I propagate the Result<T> in Rust even though the From<T> trait is implemented?
Problem
Hi. I am trying to control an accelerometer (namely the ADXL345). To make this happen in rust I found a nice crate named adxl345_driver on crates.io. I used this crate just for it's ...
0
votes
0
answers
63
views
With "cargo cache" is it possible to remove dependencies which have not been used for a while?
There is a command cargo cache which can be used to clean stuff from .cargo without just deleting the whole folder regularly (and thus having to re-download/build packages).
But either I don't get ...
0
votes
0
answers
33
views
Unable to set lamports of ListingConfig account to zero
I am a beginner in Rust and Solana. I am trying to set the lamports of the ListingConfig account to zero (trying to close the account) and transfer it to the seller's account.
Here's what I am trying ...
0
votes
1
answer
57
views
Could not compile `lazy_static`
I'm having a hard time cross-compiling an embedded Rust project that worked before for a raspberry pi. I have all the needed deps in Cargo.toml but on doing:
$ cargo build --target thumbv7m-none-eabi
...
0
votes
2
answers
101
views
Using .env file at build time in Rust
I'm coming to Rust from the JavaScript world, where you could have a .env file (git-ignored), and environmental values from this file could be made available at runtime via an npm package (say, dotenv)...
0
votes
0
answers
10
views
Cargo crashes when installing a binary
It's all in the title.
For example, when running cargo install cargo-workspaces, I get the output:
Updating crates.io index
libunwind: malformed __unwind_info at 0x1A62BE8A8 bad second level page
...
1
vote
0
answers
182
views
rust-analyzer failed to load workspace: "cargo" "--version" failed: program not found
I have Rust installed using WSL2 Ubuntu I have alredy ran basic commands like hello world in rust so cargo is working. I wanted to download the rust-analyzer in VSCODE but I keep getting that error ...
2
votes
1
answer
89
views
Cargo build failed: could not find macro `llvm_asm` in this scope
I am trying to build rust-fractal-gui but the build always fails with these errors:
$ cargo build --release
...
Compiling parking_lot v0.11.2
error: cannot find macro `llvm_asm` in this scope
--&...
0
votes
1
answer
158
views
How to specify the target_os in `Cargo.toml`?
I'm trying to write a crate that only works on linux. I have done some searches but all answers are just talking about:
add #[cfg(target_os = xxx)] in the source code
add [target.'cfg(target_os = &...
1
vote
1
answer
78
views
How to complete rustup/cargo commands?
I have rustup+rust+cargo installed using the official installation script.
How do I enable shell completions, to be able to type cargo <TAB> in the terminal and see the possible commands such as ...
2
votes
1
answer
52
views
how to benchmark parts within a function?
I have one complicated function that is doing three different things. I have a benchmark written to evaluate the performance of this function, but I want to know the performance of each thing ...