Rust is a language designed for writing highly reliable and fast software in a simple way. It can be used from high-level code down to hardware-specific code, and from big irons to tiny devices.

0
votes
0answers
4 views

Can you share `cfg!` up the dependency tree using Cargo?

Suppose you have a Rust library (call it mylib) that has some platform abstractions in the form of "backends". The library uses a build.rs to do some platform checks and sets some compile time ...
1
vote
1answer
15 views

How RUSTC and RUSTC_WRAPPER are different in Cargo?

Cargo environmental variables are explained here.RUSTC - Instead of running rustc, Cargo will execute this specified compiler instead.RUSTC_WRAPPER - Instead of simply running rustc, Cargo will ...
-2
votes
2answers
41 views

Alternative functional style written in rust

How to correct the syntax error in the section 2? An error message was shownerror[E0277] slice indices are of type `usize` or ranges of `usize`when the section 2 was compiled. (Section 1 and ...
0
votes
1answer
21 views

BigUint and “cannot move out of borrowed content” error

I tried to follow the iterator approach described in Rust by Example's Iterator section with BigUint:extern crate num_bigint;use num_bigint::{BigUint, ToBigUint};struct FibState {a: BigUint,...
2
votes
0answers
23 views

How to disable warnings on proc-macros?

I'm using the enumflags crate, which provides the custom derive EnumFlags on enums via enumflags_derive. Additionally, I'm using Clippy with write_literal enabled. When deriving a struct with ...
1
vote
1answer
57 views

When is it necessary to circumvent Rust's borrow checker?

I'm implementing Conway's game of life to teach myself Rust. The idea is to implement a single-threaded version first, optimize it as much as possible, then do the same for a multi-threaded version....
-2
votes
1answer
30 views

How can I disambiguate a mixed Iterator and Futures call chain without moving self?

I'm trying to add a Futures Stream implementation to an existing struct which already has a synchronous Iterator implementation. In order to keep the code DRY, I want to modify the Iterator ...
-2
votes
1answer
50 views

Provide `char **` argument to C function from Rust?

I've got a C function that (simplified) looks like this:static char buffer[13];void get_string(const char **s) {sprintf(buffer, "Hello World!");*s=buffer;}I've declared it in Rust:...
2
votes
1answer
33 views

How do I convert a usize to a u32 using TryFrom?

I want to convert a usize typed variable into a u32 typed variable in Rust. I am aware that the usize variable might contain a value larger than 2^32, and in that case the conversion should fail. I am ...
0
votes
0answers
23 views

#[allow(unused_must_use)] for one line [duplicate]

I have lines that return Result. The result does not matter and I don't want unwrap() or any logging. (The frequent failures are expected)How can I silence the unused warnings for only these lines?...
0
votes
1answer
45 views

Why can't I return an explicitly-typed Result enum from a function?

Simple code as below:fn main() {let R1=TestResult(10, 20);match R1 {Ok(value)=> println!("{}", value),Err(error)=> println!("{}", error),}}fn TestResult(...
0
votes
1answer
32 views

Convert &[u8] to String [duplicate]

I have a byte array which I would like to return as std::string::String. The other answers and docs I found were converting Vectors to strings. How would I convert a byte array &[u8] to a String?...
5
votes
0answers
76 views

“multiple definition of `memcmp” error when linking Rust staticlib with embedded C program

I have a Rust function I would like to call from a C project that runs on an STM32F412 MCU, but I am getting a series of "multiple definition of" linker errors.Here is my lib.rs: #![crate_type="...
-1
votes
1answer
82 views

Why does creating and writing to a very large vector cause a core dump?

I'm creating a Sieve of Eratosthenes so I can see all the prime numbers up to the starting number. Just the following code causes a core dump on Rust 1.26. There are no compiler warnings or errors, ...
6
votes
0answers
75 views

Is it safe and defined behavior to transmute between a T and an UnsafeCell<T>?

A recent question was looking for the ability to construct self-referential structures. In discussing possible answers for the question, one potential answer involved using an UnsafeCell for interior ...

153050per page
angop.ao, elkhabar.com, noa.al, afghanpaper.com, bbc.com, time.com, cdc.gov, nih.gov, xnxx.com, github.com,