As of May 31, 2023, we have updated our Code of Conduct.

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.

Filter by
Sorted by
Tagged with
2 votes
0 answers
295 views

Rust app to download, process, and upload files to S3

I've written a small server app which grabs a token from another server, downloads JSON, then downloads files referenced in that JSON, processes them with a CLI ...
t56k's user avatar
  • 121
7 votes
2 answers
774 views

Median cut algorithm

I have implemented a simple version of the median cut algorithm. It takes a vector of Color structs representing pixel in an image. I also use the ...
チーズパン's user avatar
2 votes
0 answers
102 views

CSV file aggregator (appender) CLI

My goal is to write a CLI utility that aggregate (appends) many CSV files in a lightweight and performant (my use-case involves output files in the 10s of GBs) manner. Specifically, the utility ...
Luke Carr's user avatar
  • 223
0 votes
1 answer
56 views

Rust wrapper around Win32 Fiber

So this one was quite rough to implement. I needed to pass an FnOnce to a foreign function through a c_void which requires ...
Rick de Water's user avatar
0 votes
1 answer
78 views

Image scraper using Dependecy Injection in Rust with generics

I'm writing a scraper that downloads images from a given subreddit. I'm new to Rust, and in the majority of my previous projects I was using C++ or Java, where it's easy to do Dependency Injection. I ...
aurelia's user avatar
  • 103
0 votes
1 answer
56 views

Generically calculate powers of two below a number

The following function is an attempt to generate powers of two below the input number max. So powers_of_two_below(15u8, u8::BITS)...
sshine's user avatar
  • 731
6 votes
1 answer
167 views

Rust CLI for playing Wordle

I wrote the following CLI for playing the popular word game - Wordle. Wordle is a word game in which players are trying to guess a 5 letter word. Each turn they guess one 5 letter word, and for each ...
T. Kiley's user avatar
  • 163
2 votes
1 answer
169 views

Minimum Spanning Tree in Rust

As a project I have worked on implementing and benchmarking two different minimum spanning tree algorithms in rust. My main concern is adhering to good style and not programming any glaring ...
Someone's user avatar
  • 161
6 votes
1 answer
175 views

Lexer for a Scheme-like language in rust

I was/am working on an interpreter for a scheme-like language. Just some time back I shifted my implementation from C++ to Rust, which I just started learning. I know there are parser libraries like ...
Bhargav Kulkarni's user avatar
1 vote
0 answers
83 views

Lock-Free Single Reader/Single Writer Lamport Queue

I've created a lock-free lamport queue in rust. My code should be clear enough that you won't need to understand a lamport queue before reading it, but if you'd like a reference, this paper give a ...
thesecretmaster's user avatar
2 votes
2 answers
200 views

Rust Cacher implementation (chapter 13 of the Book)

In https://doc.rust-lang.org/book/ch13-01-closures.html the author recommended to try to implement Cacher that: Stores values in a ...
mnj's user avatar
  • 155
1 vote
1 answer
1k views

How do I get the unique list of values from a hashmap in rust?

I have the following code which finds all the unique values from a hashmap of String to Vec. I cobbled it together (eventually as I was getting various borrow errors along the way), but it looks a ...
Mark Fisher's user avatar
5 votes
1 answer
332 views

Rust program to one hot encode genetic sequences from .fa files

I wanted to write some code which reads in a FASTA file and one hot encodes the sequence which is consequentially saved to a file. A FASTA file is a text based file format commonly used in ...
dry-leaf's user avatar
5 votes
1 answer
257 views

Rust CLI tool to synchronize files to S3

Learning Rust, I've written a small CLI tool which will Fetch the existing data in S3 Iterate through local folders Upload the files which don't exist in S3 I'd be keen to hear anything I might have ...
Jeroen Vannevel's user avatar
5 votes
1 answer
930 views

Processing binary data in Rust

I have binary files that need to be efficiently processed. The first 8 bytes correspond to metadata, and all the rest is data. From the first 8 bytes I need the last 4 bytes to determine how to ...
Sito's user avatar
  • 384
1 vote
1 answer
93 views

Floating point addition algorithm

I made a function in Rust to add two floating point numbers (f32s) together using only their bit representation and integer operations. I have tested it for a quite ...
isaacholt100's user avatar
3 votes
1 answer
99 views

Project Euler problem 11 in Rust: largest product of consecutive elements in a grid

I wrote the following Rust code for euler project problem 11. It works and a small test is included, but I am not very happy about the code. At first I wanted to chain together iterators for all the ...
hkBst's user avatar
  • 198
3 votes
1 answer
107 views

2021 Advent of Code, Day 1 Part 2: Keeping error-handling simple while chaining iterators with Rust

This question is with respect to Day 1, Part 2 of the 2021 Advent Of Code challenge, which requires comparing values from a rolling window taken from integers streamed as input. This answer is correct,...
Charles Duffy's user avatar
2 votes
0 answers
432 views

Parallel Breadth First Traversal in Rust

Overview I have been writing my own graph API for Rust and one thorny problem I wished to tackle was a parallel breadth first traversal of the graph. The API itself will have different graph flavours, ...
Julius's user avatar
  • 171
1 vote
0 answers
244 views

Implementing a LinkedList in Rust

I have this LinkedList implementation for rust and it isn't quite what I am looking for. Ideally, it would be more like scala's implementation of List and be entirely immutable. This implementation ...
Christian Bongiorno's user avatar
2 votes
1 answer
69 views

Pig Latin terminal app in Rust

I've started learning Rust a few days ago. This is the Pig Latin exercise from the Rust Book. The code works as expected. I have commented the logic of the program in the code. My handling of ...
user1984's user avatar
  • 123
3 votes
2 answers
948 views

Rabbit Searching Problem in Rust

This is my Rust implementation of the rabbit searching algorithm I found yesterday in this video. The problem statement is as follows. There are 100 holes in a line. A rabbit is in one of the holes. ...
Faris's user avatar
  • 133
3 votes
1 answer
475 views

Idiomatic way to extract matches from rust Regex?

I'm learning rust and doing an exercise where to parse a particular SGML document. Each line in a document can be either an opening tag "" , a closing tag "" or a scalar: " ...
user38310's user avatar
3 votes
1 answer
247 views

Reading input in idiomatic Rust for Advent of Code Day 2

I'm trying to write idiomatic and fast Rust code by solving AoC challenges this year! :-) Link to AoC Day 2 problem The input format in this problem is a list of lines each containing one string token ...
Gaurang Tandon's user avatar
4 votes
1 answer
174 views

Advent of Code 2021: day 1

I am doing the Advent of Code challenge to learn Rust (obviously there may be spoilers if you still want to do the challenge). The instructions are too long to include verbatim so I will link them and ...
NeRoboto's user avatar
  • 143
1 vote
1 answer
47 views

Rust Pig Latin Translator - Idiomatic suggestions

This is the code I came up with for the Rust pig latin exercise. I am looking for suggestions on how to make it more idiomatic. I think working with iterators instead of chars and Strings would be a ...
Samuel Page's user avatar
3 votes
1 answer
79 views

Building a trie from a vector of strings in Rust

I'm learning rust (coming from C++) and playing around with different small algorithms to understand the ownership & borrowing concepts better. Currently, I'm having difficulties finding the ...
picklepick's user avatar
1 vote
1 answer
87 views

Quickly update, clone, and iterate ball simulation

What the program does: I have made a program that simulates a ball in an area made of triangles and many optimizations because it's for high-performance ball path simulation (technically ball path ...
VirxEC's user avatar
  • 207
1 vote
1 answer
77 views

PartialOrd of Rust Enums based on encapsulated data

I have an Enum the encapsulates numeric primitives (u8, i8, u16, i16, u32, i32, u64, i64, f32, f64) into a common type called "Number". I want to implement a PartialOrd train for the enum ...
Darko's user avatar
  • 111
6 votes
1 answer
128 views

Rust based Sudoku solver using backtracking

I've just started learning rust and have written a basic sudoku solver, however it seems to run much slower than I expected. So I'm looking for any possible performance improvements as well as any ...
theAlex's user avatar
  • 63
2 votes
1 answer
168 views

Finding possible combinations for n<7 with rust

I am trying to learn rust and as such have been redoing some of the challenges on project Rosalind. This one relates to the challenge Enumerating Gene Orders. ...
mega_creamery's user avatar
1 vote
1 answer
449 views

A character shift function in Rust

As you might probably know, a Caesar cipher involves shifting/unshifting and wrapping up characters when they overflow the first or last letter of the alphabet, it's useful to have a function to just ...
Weezy's user avatar
  • 113
3 votes
2 answers
132 views

Generating prime numbers quickly in rust

I am attempting to re-implement a postponed sieve algorithm for generating prime numbers in Rust. I am able to make a solution that works, but I have to use a couple of ...
kbrose's user avatar
  • 151
2 votes
1 answer
82 views

The Rust Programming Language Pig Latin

This is my implementation of the Pig Latin recommended exercise in The Rust Programming Language book. Any pointers on making this code more idiomatic or run more optimal? ...
CGLike's user avatar
  • 121
1 vote
0 answers
116 views

Interactive browser launcher in Rust using Native Windows GUI

The program is supposed to be set as the default browser in Windows and allows me to select which browser profile I want to use when I open a link from another program. I have quite some experience in ...
Gerald Schneider's user avatar
3 votes
1 answer
316 views

Rust calculator

To learn some rust I decided to write a simple calculator. This calculator can take a string in the form of 1+2*3/4-5, and calculate the result. It does so while ...
Daniël van den Berg's user avatar
1 vote
0 answers
32 views

Generic Huffman Encoding

For my first Rust exercise I decided to re-implement a project I wrote in C++ for my data structures class a few years ago, plus make it generic. I am looking for all suggestions, but I am primarily ...
zmjackson's user avatar
4 votes
1 answer
150 views

Segmented Sieve of Eratosthenes with wheel factorisation

Problem I have a project in which I implemented variants of the Sieve of Eratosthenes as well as benchmarking and profiling harnesses for these (which can be ran with ...
nicoty's user avatar
  • 259
0 votes
1 answer
185 views

Rust way of the generic quicksort implementation

I have implemented the classical Hoare's algorithm, but I think that the implementation is not readable enough. I have tried to refactor it in the way that I used to use in C#. But now I have got ...
Mark Shevchenko's user avatar
1 vote
1 answer
36 views

Find record name from an hexadecimal record code value using bitwise "and"

I am writing a function that will retrieve the name of a certain record defined as a u32, I wanted to make the function filter the record code first in macro ...
Giuseppe's user avatar
  • 111
0 votes
1 answer
1k views

Concatenate two vectors and store the result [closed]

I code in Rust, but one doesn't need to be familiar with Rust to understand the question. We are given the two vectors, first and res. Our goal is to append res to first, and then to assign the result ...
memoryallocator's user avatar
5 votes
1 answer
190 views

Simple expression evaluator in Rust

What follows is an evaluator for a toy expression language. The language includes functions of a single variable (with lexical binding), along with numbers and a way to apply functions to expressions. ...
William Lewis's user avatar
1 vote
1 answer
119 views

Patricia tree implementation in Rust

I've implemented a map using a Patricia tree, using u64 as keys. I would like general feedback on my code, but I have one thing that I think could be implemented in ...
Tyilo's user avatar
  • 615
3 votes
2 answers
101 views

Split string at given positions

Given a vector <Vec<usize>> of indices indicating where to split a string as follows: ...
Lars Skaug's user avatar
1 vote
0 answers
316 views

Convert PathBuf to file URL in Rust

I've implemented a custom trait on std::path::Path (and by extension std::path::PathBuf) with a method which turns the struct ...
Jared Smith's user avatar
5 votes
1 answer
1k views

BST implementation in rust

I am looking for some feedback on my implementation of binary search tree in rust and I would appreciate someone taking the time to go through it and suggest any improvements or corrections as they ...
RoboT's user avatar
  • 153
3 votes
1 answer
59 views

Rust script to generate JavaScript asset list file based on directory contents

I'm new to Rust. I wanted to create a script to read the contents on a directory, and then generate a js file exporting this assets. I wrote this code, it works but I'm not totally happy with it. I ...
José Luna's user avatar
0 votes
1 answer
58 views

Avoiding cloning references in a Specs system

I'm working on a card game using Amethyst's Specs crate and am fairly new to Rust (therefore I'm learning through the fight with the compiler). My first System is ...
Daniel A. White's user avatar
4 votes
0 answers
91 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
-1 votes
1 answer
101 views

Rust: lazy_static the strings from evdev codes [closed]

So I have this piece of code that produces following error: ...
loa_in_'s user avatar
  • 129

1 2 3
4
5
16