Category "rust"

Rust: additional trait bounds in conjunction with higher-ranked lifetime bounds

I want trait implementations in Rust to be able to return arbitrary iterators (of specific item type) that may reference the original object with a lifetime 'a

Does Cargo support custom profiles?

I often want to compile in release mode with debug = true so that I can read the generated assembly a bit easier. I am currently doing this: [profile.release]

How to get the number of elements (variants) in an enum as a constant value?

Is there a way to extract the number of elements in an enum? Simple example (with imaginary number_of_elements method): enum FooBar { A = 0, B, C, }; println

Contradictory error messages calling .any() on &dyn Iterator vs &mut dyn Iterator

MCVE (simplified from real code where I may return a raw vec.iter(), or a vec.iter().filter() based on some conditions): let input = vec![1,2,3]; let dyn_iter:

Improving Rust binary build times

I’m just starting a Rust project and already it takes ~7.6s to build what I’d consider a simple binary. I’m using async/await a lot and comme

Rust tonic tonic::include_proto file path from one module to another module in tonic build

I am implementing gRPC client and server using Tonic. I have two modules each module depending on another module proto file. I am facing an issue when I try to

debugging multiple threads with visual studio code

I am setting some breakpoints in some async threaded code and I can't seem to figure out how to tell visual studio code to catch any threads in this code path.

How can I obtain access to a networked location?

My program, when started up with the system, is unable to access a networked location: fn main() { ensure_network("\\\\SERVER\\".to_string()); } fn ensure_

How to invert a `HashMap<String, MyEnum>`? (Error: "`FromIterator` not implemented for [pair]")

I'm trying to invert a HashMap<String, MyEnum> in Rust, and getting an error: Rust Playground instance Code: use std::collections::HashMap; // Directive

How to get a release build with debugging information when using cargo?

The following command $ cargo build produces a non-optimized build with debugging information. On the contrary, $ cargo build --release produces an optimi

Glob Multiple File Types

I want to find files for some pattern with multiple extensions. Ex:- some/path/**.{json,jsonc} But rust glob function is not working with these types of patt

How do I print colored text to the terminal in Rust?

How do I output colored text to the terminal using Rust? I've tried using the special escape characters that I found in this python answer, but they just print

Is there a command to update Cargo to the latest official release?

I seem to have diverging versions of rustc and cargo (I think), $ rustc -V rustc 1.9.0 (e4e8b6668 2016-05-18) $ cargo -V cargo 0.10.0-nightly (10ddd7d 2016-04

Convert two types into a single type with Serde

I'm writing for a program that hooks into a web service which sends back JSON. When a certain property isn't there it provides a empty object, with all its fie

How do you find the local timezone offset in rust

Rust's chrono::Local contains the local timezone information but does not seem to have any methods to get the value as a string or a number of seconds offset.

How to collect multiple results from concurrently working for loop?

I would like to run a function with lots of different variables Let assume my function is : async fn do_the_hard_job(my_input: u16) { ... // do the hard

Is there a way to seed a cryptographically secure RNG engine in rust using a [u8; 64] array?

ORIGINAL QUESTION: I am currently trying to write a library in rust - to be compiled to WASM - for converting a bip39 mnemonic passphrase into an Arweave JWK. I

Local crate in Rust

I am currently learning Rust, and for that purpose I wanted to create my own crate and use it. However, Rust can't find this crate. I have the following file st

How to return an iterator from a function and use it?

I'm trying to teach myself Rust by working on a little calendar project. Here I'm trying to generate a list of dates spanning three whole months around a given

When to use Rc vs Box?

I have the following code which uses both Rc and Box; what is the difference between those? Which one is better? use std::rc::Rc; fn main() { let a = Box::