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
0
votes
1 answer

Crate cannot find path

I am trying to use this crate to generate an ethereum address: https://docs.rs/ethkey/0.2.5/ethkey/ use ethkey::prelude::*; fn main() { let key = EthAccount::load_or_generate("~/", "passwd") .expect("should load or generate new eth…
0xsegfault
  • 2,899
  • 6
  • 28
  • 58
0
votes
1 answer

What to do when a dependency can be expensive to create?

I wrote a simple program to test Cloudflare's wirefilter, here is an example that works. use wirefilter::{ExecutionContext, Scheme}; lazy_static::lazy_static! { static ref SCHEME: Scheme = Scheme! { port: Int …
Jayson Reis
  • 708
  • 5
  • 14
0
votes
1 answer

Is there a problem with naming a crate containing the string ".rs"?

Could there be any future problem in naming a dependency .rs for example, [dependencies] gccjit.rs = { git = "https://github.com/swgillespie/gccjit.rs.git" } In the above code, I use .rs for something which is not a Rust source code file. Is that…
Niklas Rosencrantz
  • 25,640
  • 75
  • 229
  • 424
0
votes
1 answer

Why can I not add a main.rs to a crate's source code and import a struct?

Why can I not clone a git project, add a main.rs and import one of the structs? The compiler complains that the import is unknown and if I make it known it complains about the library file can't be compiled. My…
Niklas Rosencrantz
  • 25,640
  • 75
  • 229
  • 424
0
votes
2 answers

How to do a subtraction between &ndarray::Array1 and &mut Array1?

I find it impossible to do a subtraction between an immutable array reference and a mutable one using the ndarray crate: #[macro_use] extern crate ndarray; use ndarray::Array1; fn main() { let a: &Array1 = &array![3.0, 2.0, 1.0]; let…
asdetrefle
  • 303
  • 1
  • 6
  • 14
0
votes
1 answer

How to include documentation for unique match cases in macros?

Is is possible to write documentation for individual match cases of an exported macro. /// This macro does stuff // this works #[macro_export] macro_rules! macro{ /// Today it's time for cats // error: no rules expected the token `[` (cat)…
0
votes
0 answers

Method from RustCrypto's BlockCipherVarKey trait not taken into account

I am trying to use RustCrypto to instantiate a blowfish object. The new method is implemented by the BlockCipherVarKey trait in the block-cipher-trait crate. Here is my minimal example: extern crate block_cipher_trait; use…
Bromind
  • 1,065
  • 8
  • 23
0
votes
1 answer

Can't use the conrod library in my Rust project: can't find crate piston_window

I'm new to Rust and I'm trying to open a window with the Conrod library, like they did in the canvas.rs example: #[macro_use] extern crate conrod; extern crate find_folder; extern crate piston_window; use conrod::{Canvas, Theme, Widget, color}; use…
Omegaspard
  • 1,828
  • 2
  • 24
  • 52
0
votes
1 answer

How am I messing up these modules?

I'm trying to create a crate that has a library and one or more binaries. I've looked at Rust package with both a library and a binary? and the Rust book section on crates and modules but am still running into errors when I try and compile. I've…
Camden Narzt
  • 2,271
  • 1
  • 23
  • 42
0
votes
1 answer

Testing a custom crate

I've got this crate in/src/lib.rs which I'm trying to run tests on: #![crate_type = "lib"] #![crate_name = "mycrate"] pub mod mycrate { pub struct Struct { field: i32, } impl Struct { pub fn new(n: i32) -> Struct { …
andrey
  • 1,515
  • 5
  • 23
  • 39
0
votes
0 answers

Using items in submodules from `extern crate` in root module

My understanding is that extern crate foo; declarations in the root module are then importable in any submodule with use foo::bar. While this works in one submodule, it doesn't work in the other submodule. Any ideas why this might not work? |---…
brandonchinn178
  • 519
  • 3
  • 20
0
votes
1 answer

Rust cargo cannot find postgres package

I have this in Cargo.toml [dependencies.postgres] git = "https://github.com/sfackler/rust-postgres.git" This resulted in the following output, when running cargo build: $ cargo build -u Updating git repository…
bojangle
  • 888
  • 1
  • 8
  • 14
-1
votes
0 answers

Rust compiler "Cant find crate" for Rand

I have searched Stackoverflow and the internet far and wide for an answer to my problem but have found no fix yet. I have written a program in rust using the crates 'rand' and 'matrix'. I have added both using cargo, and added the lines extern crate…
Chuckster
  • 69
  • 1
  • 4
-1
votes
1 answer

How can i change the version of a sub dependancy of a crate?

I'm trying to build some libraries using the wasm32-unknown-unknown and I get error[E0433]: failed to resolve: use of undeclared crate or module `imp` -->…
-1
votes
1 answer

Does unreachable Rust code get compiled and included in the final binary?

I'm new to Rust and compiled languages in general. Does every crate I include as a dependency end up in the binary, even if I don't use a single function from that crate? And if I use just a single function from a big library. Does the entire…
Cornelius Roemer
  • 3,772
  • 1
  • 24
  • 55
1 2 3
13
14