# 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.

621 questions
Filter by
Sorted by
Tagged with
22 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: " ...
58 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 ...
87 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 ...
39 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 ...
37 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 ...
24 views

(From stackoverflow.com, they suggest me to post this question here) I'm trying to build a bot to check with accounts the status of a service connected to each of ...
70 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 ...
23 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 ...
60 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 ...
43 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. ...
48 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 ...
68 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 ...
61 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? ...
67 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 ...
60 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 ...
25 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 ...
74 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 ...
57 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 ...
28 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 ...
73 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 ...
82 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. ...
45 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 ...
49 views

### Rust Error Handling - Can this error handling be made cleaner?

Recently I started to learn Rust. I come from a mostly Java background, but spent roughly the last two years in Go. I am working on converting a small microservice that reads data from Kafka and ...
89 views

### Split string at given positions

Given a vector <Vec<usize>> of indices indicating where to split a string as follows: ...
53 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 ...
114 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 ...
50 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 ...
51 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 ...
56 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 ...
44 views

### Rust: lazy_static the strings from evdev codes [closed]

So I have this piece of code that produces following error: ...
149 views

### Observer pattern in Rust

A simple implementation of the Observer pattern in rust. The Observable constructor (::new) is called with a subscription function which will be called every time ...
80 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 ...
91 views

...
180 views

### Solution to LeetCode Two Sum problem in Rust

It's taking 2.4 MB of memory and 20 ms. It's my solution for Two Sum problem on LeetCode. How can I make it better using closures and other stuff? Kindly review the code. ...
105 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 ...
91 views

### Rust Persistent Red Black Tree Implementation

Below is my implementation of a persistent red black tree in Rust. I have a few questions about potential improvements. Currently the data and nodes are stored in referenced counted pointers. Is this ...
33 views

### Rust program to create mail.tm accounts

I have created a rust program to create https://mail.tm accounts, but I think there are things I could have done better. Are there things I can do to improve performance? Are there any unnecessary ...
108 views

### Rust returning multiple errors

I am learning Rust and I would like to know what is the idiomatic way of writing a function that could run into multiple error types. For instance, in the function <...
86 views

### Parallel word recognition in a Non-deterministic finite automaton in Rust

I have implemented a simple NFA that recognizes words in parallel. All the code is on GitHub, here. A main recognizes method tells if a ...
63 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 ...
102 views

### Possible improvements to window swallowing program?

I have written a small program that swallows windows. It works in X.org using the xcb library. This is my first rust program but I have lots of other programming experience. Any general improvements ...
23 views

### Fuzzy Search Table Widget in FLTK-Rs

I'm building a fuzzy search table widget in FLTK-RS. On my pretty decently spec'd machine I'm getting pretty laggy performance, does anyone have any thoughts on ways to improve this? If you'd like to ...
95 views

### Caesar cipher/beginnings of a crypto library in Rust

As a hobby project (and to learn the language), I'm working on a crypto library in Rust. The following is a component thereof, which implements encryption with and the cracking of the Caesar cipher. ...
59 views

### Async streaming of Reddit posts

roux is a Rust library that wraps the Reddit API. Neither Reddit nor roux provides a stream-like interface for obtaining the ...
142 views

### Simple terminal Game of Life in Rust

I've been learning Rust for a few weeks in my free time, and as a first project I decided to make a simple terminal Game of Life program (without UI, that might come later). It just starts with a ...
84 views

### Simplify a Unix-style absolute path

I have a match arm in rust, I think it may be simplified, but after googling and read books, I haven't find the solution. Especially for the ...
109 views

### Snake game in rust

I made a small rust snake game in order to teach myself rust. I would like to know what I am doing well and poorly, and how to improve my rust code Cargo.toml ...
73 views

### Rust Locker Problem Number Theory

The Locker Problem is as followed: Twenty bored students take turns walking down a hall that contains a row of closed lockers, numbered 1 to 20. The first student opens all the lockers; the second ...