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

Rust: Refer to a third .rs file from a second .rs file

I have three files: // a.rs struct MyThing { } // b.rs mod a; struct That { mything: &a::MyThing; } // main.rs mod a; mod b; fn main() { let thing= a::MyThing{}; let that= b::That{myThing: &thing}; } The compile error I get for…
lmat - Reinstate Monica
  • 7,289
  • 6
  • 48
  • 62
-1
votes
2 answers

buffer.write() in Rust Language starting from write() in C

I have this code in C that writes in a fd the command. My issue is that I can't represent the same behaviour in Rust language because apparently the .write() doesn't takes the same parameters as C's write(). The function is the following: static…
CLetter
  • 1
  • 2
-1
votes
1 answer

How to see annotations

In https://docs.rs/[package]/..., the RHS lists objects like "Modules, Macros, ...". However, how do you see what annotations it exposes? As a helpful example—this is not the whole question, just an example—serde_json claims to expose only the json…
Test
  • 962
  • 9
  • 26
-1
votes
1 answer

no #[repr(...)] for rust crate

I'm trying to solve a trivially simple exercism task on using external crates. use int_enum::IntEnum; #[derive(Debug, PartialEq, Eq, IntEnum)] pub enum ResistorColor { Black = 0, Brown = 1, Red = 2, Orange = 3, Yellow = 4, …
-1
votes
1 answer

How to use rust crates in offline mode

Due to our company cyber security policy, I have to work in offline mode. (From offline, here I mean, internet can never be connected to the PC, the only option is to download source on some other PC and copy it to the target PC, where I am…
-1
votes
1 answer

How to include unpublished dependencies/libraries in Cargo.toml?

I want to build a currently unpublished library and an application which uses it. How to include an unpublished library in the executable application's Cargo.toml file? From looking at the creates documentation it looks like it's something along the…
Greg
  • 8,175
  • 16
  • 72
  • 125
-1
votes
1 answer

Unresolved name `Binary` when using the ftp crate

I am downloading a file from a FTP server using the ftp crate: extern crate ftp; extern crate chrono; use std::env; use std::fs::File; use std::str; use std::io::{Result, Write}; use ftp::FtpStream; use chrono::*; fn main() { let args:…
Anton
  • 3
  • 2
-2
votes
1 answer

Rust - image crate: issue saving image buffer

I have a question related to the fractal example (section '6.2 Generating Fractals', https://github.com/PistonDevelopers/image) in examples supplied for image crate 1) At line image::ImageLuma8(imgbuf).save(fout, image::PNG).unwrap(); I get the…
TC29
  • 1
  • 2
-4
votes
1 answer

How are Rust crates (e.g. num_cpus) implemented?

I was wondering how are Rust crates are implemented. For example, there is a crate named num_cpus. This crate has this basic method num_cpus::get() which tells number of CPUs in your computer. My questions: How is the method num_cpus::get()…
1 2 3
13
14