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
5
votes
0answers
65 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 ...
2
votes
1answer
31 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 ...
0
votes
0answers
14 views

A Rust CLI app that manages Azure resource

This is my first Rust app that I've created after reading the wonderful book. I think it doesn't make sense to copy the entire source code in here, here's the link to GitHub. If I should copy the ...
6
votes
1answer
49 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 ...
1
vote
0answers
38 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 ...
1
vote
2answers
50 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 ...
1
vote
1answer
51 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 ...
5
votes
1answer
217 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 ...
4
votes
1answer
120 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 ...
5
votes
1answer
59 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 ...
1
vote
1answer
47 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 ...
3
votes
1answer
53 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 ...
3
votes
1answer
81 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,...
2
votes
0answers
122 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, ...
1
vote
0answers
38 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 ...
2
votes
1answer
46 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 ...
3
votes
2answers
114 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. ...
3
votes
1answer
66 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: " ...
3
votes
1answer
91 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 ...
4
votes
1answer
148 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 ...
1
vote
1answer
43 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 ...
3
votes
1answer
49 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 ...
0
votes
0answers
40 views

Rust infinite loop in Tokio tasks join_all() made concurrency?

(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 ...
1
vote
1answer
79 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 ...
1
vote
1answer
33 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 ...
6
votes
1answer
87 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 ...
2
votes
1answer
54 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. ...
1
vote
1answer
64 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 ...
3
votes
2answers
74 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 ...
2
votes
1answer
64 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? ...
1
vote
0answers
76 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 ...
2
votes
1answer
84 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 ...
1
vote
0answers
27 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 ...
4
votes
1answer
82 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 ...
0
votes
1answer
67 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 ...
1
vote
1answer
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 ...
0
votes
1answer
86 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 ...
5
votes
1answer
99 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. ...
1
vote
1answer
48 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 ...
0
votes
0answers
53 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 ...
3
votes
2answers
93 views

Split string at given positions

Given a vector <Vec<usize>> of indices indicating where to split a string as follows: ...
1
vote
0answers
76 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 ...
5
votes
1answer
168 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 ...
3
votes
1answer
55 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 ...
0
votes
1answer
53 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 ...
4
votes
0answers
61 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 ...
-1
votes
1answer
48 views

Rust: lazy_static the strings from evdev codes [closed]

So I have this piece of code that produces following error: ...
1
vote
2answers
185 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 ...
4
votes
0answers
88 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 ...
2
votes
1answer
99 views

Longest common subsequence — recursion and memoization

...

1
2 3 4 5
13