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
4
votes
0 answers

How to override Cargo crate Dependencies of two different versions of crate using patch.crates-io?

I am trying to patch problematic crate that is included indirectly by crates that I include in my project. But issue is, I see two different crates use two different versions of problematic crate. Using patch.crates-io, I could patch just one…
4
votes
1 answer

How to import a function in main.rs

This may be a stupid question, but I cannot seem to solve this. I have this kind of file structure: └── src ├── another.rs ├── some_file.rs └── main.rs In the some_file.rs, I want to call a function in the main.rs. So, I tried to do…
bichanna
  • 954
  • 2
  • 21
4
votes
0 answers

How to deal with crates exporting symbols with identical names

I'd like to use both just-argon2 and sodiumoxide which are bindings to Argon2 and libsodium respectively. The first I will use for password hashing, the second for encryption and more. However, because libsodium itself also includes the Argon2 code,…
SWdV
  • 1,715
  • 1
  • 15
  • 36
4
votes
2 answers

How can I emit an integer literal with a non-decimal base using the quote crate?

I'm using quote to generate code to decode assembly operations. The instruction manual for my chip uses binary values to describe the operations, so I'd like my generated code to also express literals as binary values to make it easier for me to…
Shepmaster
  • 388,571
  • 95
  • 1,107
  • 1,366
4
votes
1 answer

the trait `std::convert::From` is not implemented for `std::io::Error`

Trying to make server with actix-web & mongodb in rust. Getting error the trait std::convert::From is not implemented for std::io::Error here is my code use actix_web::{web, App, HttpRequest, HttpServer, Responder}; use…
Niraj Gawande
  • 137
  • 1
  • 11
4
votes
1 answer

How to create a fullscreen window using piston?

I was trying to create an application that opens a full-screen window using the piston crate. How can I retrieve the physical screen size in pixels programmatically? It seems an easy thing to do, but I was not able to figure that out. extern crate…
Jimmy Hypi
  • 43
  • 4
4
votes
3 answers

How to access the function in main.rs which has been written in a file in different directory in rust in same package

I want to call a function inside a main.rs file. I have made one directory name "library" inside the same src folder as main.rs exist. src/main.rs mod library; fn main() { println!("{}", library::name1::name(4)); } src/library/file.rs pub mod…
Jawwad Turabi
  • 322
  • 4
  • 12
4
votes
1 answer

Rust `unresolved import` on third party library

I want to compile a simple rust program using a third party library named warp: [package] name = "hello-world-warp" version = "0.1.0" [dependencies] warp = "0.1.18" In src/main.rs: use warp::{self, path, Filter}; fn main() { // GET…
clay
  • 18,138
  • 28
  • 107
  • 192
4
votes
1 answer

cargo build of the same code: spurious compile time errors?

I have crate A that depend on B and B depend on rust-nmea crate. If I build crate A I got bunch of errors (all of them that missed use std::error::Error;) during build of rust-nmea dependency: error[E0599]: no method named `description` found for…
fghj
  • 8,898
  • 4
  • 28
  • 56
4
votes
1 answer

How can I find out whether a crate is compatible with a specific Rust version?

If I find a crate I'd like to use, how can I find out with which versions of Rust the crate works as expected?
the-bass
  • 705
  • 1
  • 6
  • 20
4
votes
1 answer

Can't find crate for `rayon`

I am trying to find the diameter of a BST using parallelization: extern crate rayon; use std::cmp::Ordering::*; use std::ops::Index; use rayon::prelude::*; #[derive(Debug)] struct Node { left: Option>>, right:…
4
votes
2 answers

How do I access exported functions inside a crate's "tests" directory?

How do I access my libraries exported functions inside the create's "tests" directory? src/relations.rs: #![crate_type = "lib"] mod relations { pub fn foo() { println!("foo"); } } tests/test.rs: use relations::foo; #[test] fn…
fadedbee
  • 42,671
  • 44
  • 178
  • 308
3
votes
0 answers

How can I modify HTML in Rust

I am bashing my head against the wall. We have Python code that has to be migrated to one of our servers. The servers, for different reasons, have no Python, so my task was or is to migrate it. I chose Rust because I like the language, want to learn…
HammerTime
  • 31
  • 2
3
votes
2 answers

Publish only one parent crate on multi-crate project

I am creating a library, that is nearly close to its first release, so I would like to upload it to crates.io. Library has a multi-crate design, so I ended with something like: - CrateA - CrateProcMacros - CrateC - CrateD - CrateE - CrateF -…
Alex Vergara
  • 1,766
  • 1
  • 10
  • 29
3
votes
1 answer

Exporting declarative macro that uses functions defined in crate

I'm trying to export a macro that uses from some functions defined in the crate. Something like this for e.g in a crate named a_macro_a_day // lib.rs pub fn a() {} #[macro_export] macro_rules! impl_helper_funcs { use crate::a; // error…
twitu
  • 553
  • 6
  • 12
1 2
3
13 14