Category "rust"

Apparent no-op in Rust assembly output?

I was studying the x86_64 assembly for the following function: /// Returns the greatest power of two less than or equal to `self`, or 0 otherwise. pub const fn

using iodbc in Rust

I'm trying to connect to FileMaker through a Rust application (don't ask me why...) - and I run into the wall of the FM ODBC driver being built against iodbc an

How use postgres (deadpool-postgres) with WebSocket Actix (actix-web-actors)

How to use database connection from a WebSocket handler. It is possible to use future.into_actor or ctx.spawn or actix::fut::wrap_future but that's not accurate

Why are the changes I make to my Rust program from VS Code not reflected when I compile?

I'm having a problem with Rust that I strongly suspect has do with a disconnect between Cargo and VS Code. I build my Cargo project with cargo new project I ed

Are nested structs supported in Rust?

When I try to declare a struct inside of another struct: struct Test { struct Foo {} } The compiler complains: error: expected identifier, found keywor

How can I use a HashMap with f64 as key in Rust?

I want to use a HashMap<f64, f64>, for saving the distances of a point with known x and key y to another point. f64 as value shouldn't matter here, the fo

How to combine two vectors of references without consuming an iterator?

I want to combine two reference vectors and convert them into a vector of values without consuming an iterator. Situation: Generate vectors by iterating over sp

How to POST a file using reqwest?

The documentation for reqwest v0.9.18 shows the following example of posting a file: let file = fs::File::open("from_a_file.txt")?; let client = reqwest::Clien

How to skip the first item(s) of an iterator in Rust?

When iterating over arguments (for example) thats the most straightforward way to skip the first N elements? eg: use std::env; fn main() { for arg in env

How to find X in a HashMap of HashMaps?

Given that I know ParentId and ChildId, how would I find the UserId if the hashmap is: HashMap<ParentId, HashMap<ChildId, HashMap<UserId, Foobar>>

How to avoid zombie processes when running a Command?

A small Iron project calls a Command in some route and returns a Response. Here is the relevant code of the route handler function: fn convert(req: &mut Re

Why is capitalizing the first letter of a string so convoluted in Rust?

I'd like to capitalize the first letter of a &str. It's a simple problem and I hope for a simple solution. Intuition tells me to do something like this: le

In Rust, is there a way to iterate through the values of an enum?

I come from a Java background and I might have something like enum Direction { NORTH, SOUTH, EAST, WEST} and I could do something with each of the values in tur

concat string using format!() and return to &'static str [duplicate]

I'll get error when compiled: 'returns value referencing data owned by the current function' here's the code: fn return_static_str(a: &'st

Pick preferred implementation on conflicting trait implementation (using negative bounds)

I am working on a Rust program where I got stuck on a problem that can be reduced to following case: struct Pair<L, R> { left: L, right: R, } // Retu

Is there an equivalent of JavaScript's indexOf for Rust arrays?

var fruits = ["Banana", "Orange", "Apple", "Mango"]; var index = fruits.indexOf("Apple"); let fruits = ["Banana", "Orange", "Apple", "Mango"]; let index = fru

How to overlay data structures?

I have an 8k buffer of bytes. The data in the first part of the buffer is highly structured, with a set of variables of size u32 and u16. The data in the later

How do we install rustc, cargo for all the users in the same linux machine?

I have a ubuntu machine with multiple users some of whom have and have not root privileges. Above that I have a limited storage for the same machine. I really d

How do we install rustc, cargo for all the users in the same linux machine?

I have a ubuntu machine with multiple users some of whom have and have not root privileges. Above that I have a limited storage for the same machine. I really d

How do I write a GROUP BY or HAVING clause in Diesel?

I'm trying to convert the following SQL query into corresponding Rust Diesel code: SELECT COUNT(*) FROM BookStore WHERE BookName IN ('Lord of the Rings', 'Hobbi