Category "rust"

shadertoy's GLSL and Rust Bevy WGSL incoherence

I'm trying to get into Shaders and decided to init a project using Rust and Bevy, the objective is to reproduce a raymarching shader just to confirm that the en

how to store a closure to map and call it in another thread?

I just try to write a consumer for rocketmq with rust, and have a PushConsumer like below: pub struct PushConsumer { consumer: Consumer, handler_map: Ha

how to store a closure to map and call it in another thread?

I just try to write a consumer for rocketmq with rust, and have a PushConsumer like below: pub struct PushConsumer { consumer: Consumer, handler_map: Ha

Is it possible to initialize a reference to ones self without needing to use an Option?

I'm building a circular linked list using an arena for the nodes. If I use a struct like the following it works fine: struct Node<'a> { next: Cell<Op

How to share same implementation and maybe share fields

How can I simplify this code? I still can't wrap my head around rust's traits and structs after OOP. struct Player { entity: Entity, hp: i32, atk: i

actix-web: limit upload file size

I successfully uploaded the file referring to this example, but I don't know how to limit the size of the file, for example I can't save the file more than 5M [

How can I pattern match Option in rust? Current code keeps panicking

I am working on a simple binary search algorithm in rust. It returns an Option<usize> and I am trying to pattern match on the return value. My code curren

HashMap with key referring a field in the value [duplicate]

I want to create a hash map from a vector of entities. I want the key to be a reference to a field in the corresponding value. This is somethi

How to use if let statement with conditions?

I know it's possible to express AND logic between if let statement and a condition like this if let (Some(a), true) = (b, c == d) { // do something } But w

Loading wkhtmltopdf DLL (`wkhtmltox.dll`) on Windows

I have installed wkhtmltopdf using the Windows installer and am using the wkhtmltopdf crate. wkhtmltopdf is installed at C:\Program Files\wkhtmltopdf, which con

How Can I Hash By A Raw Pointer?

I want to create a function that provides a two step write and commit, like so: // Omitting locking for brevity struct States { commited_state: u64, //

Create macro to simplify declaration of deeply nested enum?

I want to use deeply nested enums to represent blocks in my game: enum Element { Void, Materal(Material) } enum Material { Gas(Gas), NonGas(NonGas) } enum NonGa

Check 2 keys for Vacant

I am using the HashMap to store some of the value. Now I want to check whether HashMap contains keys, if not insert data else return HashMap is not empty. Below

Explicit lifetime annotations toy example

I'm trying to figure out a Rust lifetime issue and after boiling it down a bunch, I realized that I have no idea how I would explicitly annotate the lifetimes o

Lifetime on a single argument function

I've read the Rust Book and some other tutorials on lifetimes. I thought I was understanding lifetimes as like a generic parameter that a function takes, and th

Rust generic value memory store implementation

I am working on an API for an object store, and I am struggling to figure out a way to implement it in Rust. It is a bit frustrating, since I have a good idea o

Path always returning false when trying to manually put a path with Rust

I've been learning Rust, and I'm having a bit of a problem with this code. let path = Path::new(&return_path); // return path is the user input println!("{

Rust - return a future in a closure

I am trying to add a return type of a future in a closure. But the compiler is telling me that `impl Trait` only allowed in function and inherent method return

Deserializing adjacently tagged data with special characters

I have JSON data that I need to deserialize, where the format is [ { "tag": "path\like\string", "data": [{"fieldA": 1}, {"fieldA": 2}] }, { "t

Rust throws an error when running code with OpenCL

I do not know rust at all, but I know a little C / C ++, tell me why this code causes an error? I just copy/paste it use std::fs; use std::ffi::{CString}; use o