Skip to main content
Share Your Experience: Take the 2024 Developer Survey

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.

194 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
15 votes
0 answers
247 views

Download files in parallel

This module has a ensure_downloaded function which takes a slice of Urls. It downloads all of the urls to a local downloads ...
Winston Ewert's user avatar
8 votes
1 answer
372 views

Metropolis Monte Carlo Sampler in Rust

the following is an implementation of the standard Metropolis Hastings Monte Carlo sampler. You can read more about it here. At the end I am going to give you a link to the Rust playground, so you ...
Theodor Johnson's user avatar
6 votes
0 answers
98 views

Chapter 8 Challenge: Add employee names to a department

The boring but exciting challenge: Using a HashMap and HashSet, create a text interface to allow a user to add employee names ...
lml's user avatar
  • 61
6 votes
0 answers
147 views

Efficiently generate distinct subsets which sum to a particular value

Related: Find all distinct subsets that sum to a given number This code is supposed to efficiently generate all subsets of a list such that the subset's values sum to a particular target value. For ...
coriolinus's user avatar
6 votes
0 answers
177 views

Simple-ish Rust implementation of 'cat'

I've seen some other implementations of cat (even in Rust) on this site, but none attempted to completely implement the GNU cat CLI as far as I can tell. This version that I am developing is complete (...
onContentStop's user avatar
6 votes
0 answers
296 views

Generating integer partitions

I've tried to implement integer partition algorithm as described in blogpost below (author implemented it in Python): Generating integer partitions I'm still trying to learn best practices in ...
Kamil Niski's user avatar
6 votes
0 answers
197 views

Character-based transitions (part of a lexer)

As part of my prep for the Code Review community-challenge (which looks like it will be Write your own programming language), I've been working on an LL(1) lexer generator in Rust. Yes, lexer ...
CAD97's user avatar
  • 1,944
5 votes
0 answers
35 views

Procedural macro to derive de/serialization trait from/to little endian bytes

I wrote a trait library that allows the de-/serialization of data structures from/to little endian bytes 1. For it I now wrote my first procedural macro 2 to be able to derive the traits ...
Richard Neumann's user avatar
5 votes
0 answers
252 views

All pairs/Cartesian multiplication of iterators in rust

crustaceans! This is my attempt at creating an all_pairs operation for rust iterators. The code has to generate a new iterator which, when iterated, produces all ...
Arshia001's user avatar
  • 151
5 votes
0 answers
51 views

after initial r*view here is a rewrite of my c++ timerqueue ported to rust

Purpose. Provides a background task queue so that code can ask for a function to be run at a specified point in the future. They indicate what to run (a closure) and when to run it (also a name just ...
pm100's user avatar
  • 791
5 votes
0 answers
465 views

recursive-file-watcher in rust

hello guys i made a file watcher in rust using notify crate that watches a directory and if it detects file changes it will copy all of the files within the directory to another directory,i wanted you ...
mdrokz's user avatar
  • 51
5 votes
0 answers
286 views

almostIncreasingSequence

This is assignment from codesignal: Given a sequence of integers as an array, determine whether it is possible to obtain a strictly increasing sequence by removing no more than one element from the ...
rofrol's user avatar
  • 161
5 votes
0 answers
174 views

Tetris clone in Rust using specs

In order to get a hang of the ECS paradigm of game making, I decided to try my hand at making a clone of Tetris. I am using the specs crate for Rust in order to ...
Arthur's user avatar
  • 193
5 votes
0 answers
936 views

A multithreaded, growable vector with immutable elements, which has wait-free reads

Disclaimer for future readers: We experimented around with a similar approach at HASH. The linked Pull Request is working. I wrote a small vector with a few lines of unsafe Rust. The idea is to have ...
Tim Diekmann's user avatar
5 votes
0 answers
237 views

Drawing the Mandelbrot with multiple threads in rust

The code below draws the mandelbrot set for { z | z∈ ℂ, -2.2 ≤ Re(z) ≤ 0.6, -1.4 ≤ Im(z) ≤ 1.4} into a 300×300px png image. For each pixel, if the sequence {zi} is found to ...
Yosh's user avatar
  • 287
5 votes
0 answers
435 views

HashMap exercise, Rust book Ch.8

I'm learning Rust by learning the Rust programming language book. I'm now implementing the solution for the third challenge. Using a hash map and vectors, create a text interface to allow a user to ...
afgomez's user avatar
  • 151
5 votes
0 answers
189 views

Huffman encoding in Rust

An implementation of Huffman encoding / decoding as a learning exercise. I'm still new to Rust, so any tips about making things more natural for the language are appreciated. ...
user673679's user avatar
  • 11.8k
5 votes
0 answers
2k views

Converting an absolute Path to a relative one

I've this code that I use in some tool, and I wonder if it can be improved: ...
tshepang's user avatar
  • 742
5 votes
0 answers
161 views

Multiple rusty Sieves of Eratosthenes

To get more familiar with the multi-threading aspects in the Rust language I decided to multi-thread my earlier implementation of The rusty Sieve of Eratosthenes. I have to say that it is probably in ...
skiwi's user avatar
  • 10.6k
5 votes
0 answers
426 views

Simple graph in Rust

I have written simple code to construct a graph, but I think there are too many different types for such a simple task. In this code I need to store Node structs ...
Haru Atari's user avatar
5 votes
0 answers
894 views

Recursive factorial calculations in Rust

I am trying to calculate very large factorials. I am looking to speed it up as 10000! takes approximately a minute and a half. ...
Jared Mackey's user avatar
4 votes
0 answers
75 views

Implementation of Kirkpatrick-Seidel convex hull algorithm and comparing against Jarvis-March

Introduction I wanted to implement the Kirkpatrick-Seidel(KPS) convex hull algorithm and chose Rust as my language. I referred to the original KPS paper and tried to implement as closely it as ...
Saphereye's user avatar
  • 233
4 votes
0 answers
61 views

A safe building block for self-referential structs in Rust, without macros

I recently had this (admittedly slightly crazy idea) on how to design a building block that can be used in safe Rust to build self-referential structs. Unlike gsrs or selfref it works completely ...
Feanor's user avatar
  • 243
4 votes
0 answers
114 views

A simple local API proxy

Recently I needed to support someone who wanted to ingest some data from on of our API's but had tooling that struggled with the authentication bit. While I'm sure there are some off-the-shelf ...
ChrisWue's user avatar
  • 20.3k
4 votes
0 answers
111 views

Barebones DNS Client in Rust

I'm starting to learn about networking and as a project I am building a really simple DNS client in Rust. Functionality to start was just to take a command line domain argument and sending a DNS A ...
matthewmturner's user avatar
4 votes
0 answers
523 views

A safe type-erased Fn Pointer in rust that can be used to call associated and regular function

I am implementing a callback method to replace the use of generics. For maximum performance, it is not allowed to use Box and I also don’t want to use ...
JiaHao Xu's user avatar
  • 141
4 votes
0 answers
143 views

LeetCode 1632: Rank Transform of a Matrix in Rust

This is a problem-solving code for LeetCode 1632. Given an \$m \times n\$ matrix, return a new matrix answer where ...
prehistoricpenguin's user avatar
4 votes
0 answers
153 views

Small generic helper library for working with recursive data structures

I've written a small rust library that solves rust's problems with using recursive data types (e.g, linked lists). using the library, you can use ...
user3329719's user avatar
4 votes
0 answers
86 views

Fast compression using a thread pool

This is my latest effort on RFC 1951 compression ( the widely-supported compression standard ) in Rust. It uses 2 extra threads to compute the LZ77 matches and the checksum in parallel with the ...
George Barwood's user avatar
4 votes
0 answers
219 views

Tar file utility - Rust

I've been working on building a Rust version of GNU tar following the spec here. As of right now, I've got the binary accepting a single argument, the path to the file/directory to tar, which is ...
Darendal's user avatar
  • 141
4 votes
0 answers
292 views

Function composition in rust

In rust fp-core crate there is a compose function, but it is very limited for my liking. So I made a macro which uses the function composition syntax of Haskell. I would like to know why fp-core didn'...
julia's user avatar
  • 41
4 votes
0 answers
119 views

Implement a micro service in Rust

Last year I tried to implement a micro service architecture in Rust. It was asked as a homework question in an employment interview process to be completed in a few days. The imagined use case was a ...
Simson's user avatar
  • 305
4 votes
0 answers
270 views

Rust Iterative and Recursive Merge Sort Implementation

I'm in the process of learning both Rust and algorithms after primarily focusing on web development. As such I've had a go at implementing merge sort both iteratively and recursively. I've looked for ...
Naaman's user avatar
  • 71
4 votes
0 answers
124 views

Molecular .pdb File Reader in Rust

I am new to rust and wanted to get going with a medium-sized project to help learn. I've settled on creating some basic quantum mechanics code which starts with this bare-bones file reader. It takes a ...
QuantumChris's user avatar
  • 1,385
4 votes
0 answers
165 views

SHA256 implemented in Rust

I just finished making an implementation of a SHA256 hashing function (https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf) in Rust and I was looking for some feedback. As far as I can tell it ...
user668074's user avatar
4 votes
0 answers
380 views

Wait free triple buffer primitive

I'm trying to write a triple buffer that's wait free for a update + render loop after being bitten by lock starvation one too many times (on a different project, using a library). For reference, a ...
AlterionX's user avatar
4 votes
0 answers
588 views

Simple routing in Rust

After my last attempt, I started to learn Rust again. This time I wrote a simple HTTP router. I would appreciate it if you could help me to fix my mistakes. Here is the link of the repository main....
Saeed M.'s user avatar
  • 433
4 votes
0 answers
57 views

Translating Python to Rust: reading a Salesforce ID from a string

As a first project in Rust, I'm translating an existing, working piece of Python code. This code's purpose is to convert a 15-character Salesforce Id (which is guaranteed to be ASCII, exactly 15 bytes ...
David Reed's user avatar
4 votes
0 answers
468 views

Move-generation for chess in rust

In the last couple of days I have been programming a chess move generator in Rust from scratch. While it's intent is to be later used in a fully functional engine, where the speed of the move-...
Fabian v.d.W's user avatar
4 votes
0 answers
288 views

Collatz fractal in Rust

Among the many fractals, there is Collatz Fractal based on a complex extension of: $$f(x) = \left\{ \begin{array}{ll} \frac{x}{2} \space \text{if even} \\ 3x + 1 \space \text{if odd} \end{array} \...
Dair's user avatar
  • 5,906
4 votes
0 answers
260 views

Bisection and Newton's method for finding a root of an equation

In an attempt to learn Rust, I've written up implementations of the bisection method and Newton's method for finding roots of an equation. Both methods come in two variants: the first one searches for ...
Michail's user avatar
  • 459
4 votes
0 answers
721 views

Finite Automata stub in Rust

I wrote a finite automata implementation in C years ago. C's access to mutable, unsafe, raw pointers made it quite simple for me to link/relink the states of a finite automata. I read the official ...
John's user avatar
  • 323
4 votes
0 answers
54 views

Parsing λ-terms using a very simple grammar

This is my first Rust program. It parses a string into a λ-term using a very simple grammar. Please evaluate style and use of ownerships / borrowing. ...
MaiaVictor's user avatar
  • 1,101
4 votes
0 answers
1k views

Red-black tree in Rust

Although I have done a few toy projects in Rust, I haven't really done anything related to tedious memory management tasks. So I set out to create a database with the help of the project 500 lines or ...
Htet Aung Shine's user avatar
4 votes
0 answers
368 views

Knapsack 0-1 in Rust

Here is an implementation of Knapsack in Rust. How could it be improved? Some things I have already spotted: What would be the best way to extract result? Is using an option preferred unwrapping the ...
epsilon8's user avatar
  • 141
4 votes
0 answers
442 views

Lexer with a parser combinator

A follow up to my previous question which was on the token library that this lexer produces a stream of. View the full project, the tokens library, the parser combinator library, or this lexer ...
CAD97's user avatar
  • 1,944
4 votes
0 answers
3k views

Read and Write TCP Streams

I am working on an in memory on disk cache and am using TCP to send data between the client and server Testing locally things seem to be working alright. I've written a small test client so I can ...
rykeeboy's user avatar
  • 141
4 votes
0 answers
90 views

Bit Vector implementation

Looking for a general review. ...
MAG's user avatar
  • 2,934
4 votes
0 answers
250 views

Heap sort in Rust

The tests are taken from this answer on an insertion sort in rust question. The algorithm is taken from Algorithms in a Nutshell (2nd Edition). I'm not looking at crazy performance, the goal being ...
little-dude's user avatar
3 votes
0 answers
28 views

Benchmarking type generic algorithms on type heterogenous problem sets in Rust

I need to benchmark the different code generations of a generic function in rust, for different type parameters. I ran upon this when developing differential equation solvers using ...
LudvigH's user avatar
  • 131