Skip to main content

Questions tagged [rust]

Rust is a systems programming language focused on three goals: safety, speed, and concurrency. It maintains these goals without needing a garbage collector, making it a useful language for a number of use cases other languages aren't good at: embedding in other languages, programs with specific space and time requirements, and writing low-level code, like device drivers and operating systems.

2 votes
1 answer
75 views

Rust Library Design: Enum-Based vs TypeId-Based Plugin Registration for Trait Objects

I'm building a Rust library that supports multiple analysis reports, all implementing a common Report trait. I'm considering two design approaches and would appreciate a code review focusing on ...
Avi Shah's user avatar
1 vote
0 answers
46 views

Async Rust UdpServer with Clean-Shutdown (using Tokio)

I'm new to Rust and trying to build an async Server. The server should receive UDP packets, process them (which will include more network communication), and respond the result to the client. I had ...
x539's user avatar
  • 201
6 votes
2 answers
173 views

Parsing HTTP headers from &HashMap<String, String> into http::HeaderMap

For context, I'm very new to Rust, and I'm trying to learn the best practices and nuances of it as I go. I've written this small function that takes a ...
Jessica's user avatar
  • 910
6 votes
3 answers
451 views

`repeat_and_join` function for strings and chars in rust

Background I'm trying to write a helper function for constructing repeating strings with a separator. ...
Felix ZY's user avatar
  • 183
5 votes
1 answer
125 views

Macros that won't compile in release builds

We all have put in debugging statements, like println!("Here"), when we're trying to diagnose an issue. Often, especially at work, I forget to remove ...
Daniel Walker's user avatar
7 votes
1 answer
236 views

Optimizing a Rust permutation chooser for the most subsequences

I had semi-recently asked a question (well a couple closely related questions) on math.stackexchange. The simplest question is phrased as follows: You are allowed to make 3 permutations of length n. ...
Dair's user avatar
  • 6,220
11 votes
4 answers
2k views

Builder pattern in Rust

I tried to implement Builder pattern, a popular design pattern for constructing objects consisting of different components, in Rust. Here is my attempt: ...
kiner_shah's user avatar
4 votes
1 answer
136 views

Higher-kinded types in Rust

Also posted on Reddit. As a small personal exercise, I'm trying to implement a notion of higher-kinded types in Rust using type-level defunctionalisation based on the "Lightweight higher-kinded ...
nicoty's user avatar
  • 329
6 votes
1 answer
584 views

Testing a user submitted python function

I am creating a website with coding questions. When a user submits a code for a question I use the contents of the question to create a python file and then I send it to the piston API for evaluation. ...
Doruk's user avatar
  • 423
1 vote
2 answers
149 views

Translating an image encoded as u32 to an array

I have a function in an embedded system which translates an image encoded in a 32-bit integer to 3x9 matrix (an array of arrays): ...
Simson's user avatar
  • 337
2 votes
0 answers
77 views

Basic Rust server + client to handle future game logic

I made a really basic server and client in Rust using tokio for the server. I would like to receive feedback on the (very limited) code I have so far, just to make sure I'm on track to follow Rust's ...
Ajawdsa's user avatar
  • 21
1 vote
1 answer
115 views

Creating functions that send and receive atomic messages in Rust paradigm

I'm converting a library from C to Rust, and I want to see if this is the optimal way to implement network communication. This ...
Jonathon Anderson's user avatar
1 vote
2 answers
339 views

Fibonacci sequence generator

I have a piece of code that attempts to reduce the work and span in making a Fibonacci sequence. My approach is to parallelize the code as much as possible, along with doing matrix multiplication and ...
Droid's user avatar
  • 119
5 votes
1 answer
135 views

File system regex searcher

This is my first Rust project (I'm primarily a C guy). I want to know if my code is properly idiomatic (Rusty?). Also, are there any inefficiencies? The code defines an iterator (...
Daniel Walker's user avatar
4 votes
3 answers
154 views

Number guessing game in Rust

I am learning Rust and would like a review to make sure I am following best Rust practices before continuing. The user enters a number between 1 and 100 up to 6 times to guess the randomly-generated ...
Hosch250's user avatar

15 30 50 per page
1
2 3 4 5
59