Questions tagged [rust-crates]

Crates are the unit of compilation in Rust.

Crates are the unit of compilation in , and the basic building block of its system.

The crates can be published in crates.io, the official Rust packages registry, where you can browse them.

206 questions
1
vote
0 answers

Can't find local crate specified in Cargo.toml even though main.rs exists

I am trying to understand how to use local crates. I have the same problem as specified in How to use a local unpublished crate?, but the answers do not solve my problem. File structure: |--my_program | |--Cargo.toml | |--src | …
1
vote
1 answer

Linking against binary crate

There's a crate I want to use as a library for some of my own code (speedtest-rs specifically, but it doesn't really matter). However, whenever I try to use this crate, the compiler doesn't want to play nice with it. $ cargo build Compiling…
ollien
  • 4,418
  • 9
  • 35
  • 58
1
vote
1 answer

Failed to build dotenv v0.15.0 - rust cargo

I'm facing a problem trying to build a project that uses this this crate. I'm running inside the docker rust:1.44.0. I have installed the nightly: rustup toolchain install nightly info: syncing channel updates for…
Rodolfo
  • 1,091
  • 3
  • 13
  • 35
1
vote
1 answer

How to initialize generic array with generic-array crate in rust?

I use the generic-array crate: struct Foo> { data: GenericArray } But it doesn't explain how to initialize value: impl> Foo { pub fn new() -> Self { Self { data: // What…
Narann
  • 819
  • 2
  • 8
  • 20
1
vote
0 answers

cargo install async-std fails

when In run "cargo install async-std" on Windows with latest rust 1.39 I get the following error message: error: specified package 'async-std v1.0.1' has no binaries How can I solve this?
Martin Bammer
  • 537
  • 7
  • 19
1
vote
1 answer

Why does clap fail to compile when added to Cargo.toml?

Summary I'm fairly new to Rust and decided to use it to port an existing project into it. I intended to use clap to handle CLI options, but I keep getting errors. What do I need to do for clap to install correctly so that it's usable in my project…
code_dredd
  • 5,915
  • 1
  • 25
  • 53
1
vote
0 answers

Split main.rs into files that refer each other

I have the following structure: |-- Cargo.toml |-- src | |-- file1.rs | |-- file2.rs | `-- main.rs src/file1.rs pub fn function1() {} src/file2.rs // ERROR (1): error[E0583]: file not found for module `file1` // mod file1; use…
fcracker79
  • 1,118
  • 13
  • 26
1
vote
1 answer

Parsing a 50 digit integer from a csv file: ParseIntError { kind: Overflow }

What is the maximum number of digits that can be parsed as u128. I am encountering Err(ParseIntError { kind: Overflow }) while trying to parse 50 digit positive integer. My error: ... ... result: id 89…
Bussller
  • 1,961
  • 6
  • 36
  • 50
1
vote
1 answer

Rust lifetimes, data flows into other references

I wrote the following code that filters a stream of data which worked fine until I changed from parsing simple numbers to also have types that are bound to lifetimes like &str and &[u8]. use wirefilter::{ExecutionContext, Filter,…
Jayson Reis
  • 708
  • 5
  • 14
1
vote
1 answer

How to use wirefilter over an infinite stream of data

I am writing a program to use wirefilter in order to filter data from an infinite stream. But it seems that I cannot use a compiled ast in a loop because of lifetimes and when I try to compile, this is the output: error: borrowed data cannot be…
Jayson Reis
  • 708
  • 5
  • 14
1
vote
1 answer

Linker cc not found when cross-compiling simple crate on Travis CI

As part of one of my projects, I have to cross-compile a Rust crate from x86_64 to i686 on Linux. I'm currently using Travis CI for this, with a simple Hello World crate (the default binary crate). My Travis CI configuration for the relevant matrix…
Arnav Borborah
  • 11,357
  • 8
  • 43
  • 88
1
vote
0 answers

External dependency in Rust not loading from cargo run command

I am attempting to replicate code I found in a tutorial. I am using the following dependencies in my Cargo.toml file: [dependencies] iron = "0.5.1" mime = "0.2.3" router = "0.5.1" urlencoded = "0.5.0" I receive the following error message when I…
David Kamer
  • 2,677
  • 2
  • 19
  • 29
1
vote
0 answers

Use same struct across multiple test files

I have two test files located in the tests directory. Each test file contains a test function and a common struct. For example, they both contain: #[macro_use] extern crate serde_derive; #[derive(Deserialize)] struct MyStructure { a_value:…
jean553
  • 621
  • 10
  • 29
1
vote
1 answer

Install unregistered crate with cargo

I have a crate (https://github.com/wilbertom/bichannels) that is not registered on crates.io. I would like to add it to my current crate, as a dependency. I've tried going into its directory (placed inside the outer crate) and running cargo install,…
Alexis Dumas
  • 1,299
  • 11
  • 30
1
vote
1 answer

Why do I need to use an extra `::` prefix to access an imported struct?

In my lib.rs I wanted to do use std::fs::File. Here is the example code: use std::fs::File; use std::io::Read; impl Css { pub fn save_result_to_file(file_to_save: String) { println!("Saving output to {}", file_to_save); let mut…
abdoe
  • 359
  • 1
  • 4
  • 11