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.

Filter by
Sorted by
Tagged with
1 vote
0 answers
34 views

Compare and merge sets from unstructured variables for automatic differentiation

I have developed an automatic differentiation module for my software. Usually AD comes in two forms; forward mode or reverse mode and very clever approaches, beyond me, might mix both. Typically the ...
Attack68's user avatar
  • 341
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
1 vote
0 answers
25 views

Can I use only mutex and condition variable Instead of the Banker's Algorithm?

I've been studying the Banker's Algorithm and was curious if I could implement a similar resource management system using only Mutex and Condvar. The code I wrote is a synchronization program that ...
ybjeon01's user avatar
0 votes
0 answers
60 views

Simulated Annealing Variant for Conway's 99 Conjecture

I have made an algorithm that simplifies the "temperature" aspect of simulated annealing in an attempt (for fun) to solve Conway's 99 Conjecture. A brief explanation of Conway's 99 ...
Dair's user avatar
  • 5,906
4 votes
1 answer
344 views

Better way to add attributes to an enum in Rust for code scalability

I watched a YouTube video (https://www.youtube.com/watch?v=z-0-bbc80JM) talking about the power of enums in rust for data modelling. In the video, there's an example of a state machine of a simple ...
rafaelgdgs's user avatar
2 votes
0 answers
24 views

Alternative to Arc<Mutex> and clone() when using multiple variables in a callback

I'm new to Rust, and I'm working on an exercise to develop a parking lot system using the Raspberry Pi GPIO and socket.io. After some struggle, I managed to create a program that actually works, but I ...
Eduardo Rodrigues de Farias's user avatar
5 votes
2 answers
356 views

Brocard's Conjecture Candidate Finder

For fun I wanted to investigate Brocard's Conjecutre. That is, does there exist \$n, j\$ such that \$n! + 1 = j^2\$. The method I use takes inspiration from looking at divisibility rules which I ...
Dair's user avatar
  • 5,906
2 votes
0 answers
63 views

Rust implementation of a BTree

I'm studying rust, and I decided to implement a BTree as a way of learning the language. Can anyone give me suggestions on the code? As the language has no inheritance, and we must replace it with ...
Lucas Paixão's user avatar
2 votes
0 answers
126 views

Rust implementation of an algorithm I invented (RANDEVU) #2

I came up with an algorithm and created a Rust implementation of it. I've already posted it for code review previously but created another post since I've made many changes to it, including the ones ...
TypicalHog's user avatar
0 votes
0 answers
42 views

Rust Observer/Subscriber design pattern

I have written a sample Observer/Subscriber design pattern where, in my application there is a networ_receiver thread, ...
Harry's user avatar
  • 429
2 votes
0 answers
52 views

Simple Profiler in Rust

I am writing code for a simple 'Profiler', using a struct, a hashmap, Options, and some methods. I call the profiler at many places in my code with the functions names, and the hashmap gets fed, ...
user24615633's user avatar
1 vote
0 answers
32 views

Collecting inputs from a list of file names or stdin if there is no input files

In my program, I want to either read from a file or stdin depending on the arguments. I did this function to collect input: ...
Fayeure's user avatar
  • 111
2 votes
1 answer
54 views

Basic rust Celsius to Fahrenheit conversion

I've been following the rust book, and I made a Celsius to Fahrenheit converter as it advised me. After a bit, I came up with this code; however in my opinion, there's a lot of unnecessary parts that ...
icy icy's user avatar
  • 23
1 vote
0 answers
46 views

Simple CRUD server in rust

This is my first rust application. I tried to pick somewhat low level dependencies to get a feel for the language particulars. I'm especially interested in control flow/error patterns in rust as I ...
intentionally-left-nil's user avatar
3 votes
0 answers
43 views

Created client server with read and write from both side

I have created client and server which can read and write from both side in client as well server. So what more improvement can be done so the code should be performant and better? Following are three ...
i_am_learning's user avatar
4 votes
1 answer
84 views

Rust Wake-on-LAN CLI

I'm new to writing rust code, and looking for any alternate approaches to writing this code or changes to make it more idiomatic, and readable. My use of traits, specifically, I dislike. It feels like ...
freebie's user avatar
  • 191
5 votes
1 answer
174 views

Sand simulation in Rust

I am working on this project to learn Rust and a bit of Web Assembly. The rendering is done in JavaScript which I do not really care about so I will not post. I would like to receive some harsh ...
Doruk's user avatar
  • 203
1 vote
0 answers
53 views

Rust minesweeper grid generator code design

I wrote this not really to create a minesweeper game, but to practice using some of the "rusty" (but not only) design patterns and improving my code structure. I would appreciate a review of ...
Imaginary's user avatar
4 votes
0 answers
74 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
3 votes
0 answers
131 views

ASHv2 implementation from scratch - host, transmitter and listener

I am currently implementing the EZSP and the underlying ASHv2 protocols in Rust with the intention to use them on an embedded smart home gateway to control ZigBee devices. In this review I present you ...
Richard Neumann's user avatar
4 votes
1 answer
67 views

Parsing command line arguments with CLI

I'm new to rust, and this is my very first rust program. I'd like to write a simple CLI app to help me running some Git command on multiple repositories. Since my goal is learning rust, I force myself ...
Marcus's user avatar
  • 41
5 votes
3 answers
696 views

Rust: Command line menu in ASCII table

Specific areas in which I'd love to get feedback: Is it good to have the Command struct own the Strings (...
m01010011's user avatar
  • 153
3 votes
0 answers
69 views

Sum all numbers touching symbols in 2D grid (Advent of Code 2023 Day 3, Part 1)

Please offer suggestions to my below Rust approach for solving AoC 2023 Day 3, Part 1. The code is functionally correct, so I'm interested in understanding how I could have solved it in a more ...
naivedeveloper's user avatar
4 votes
1 answer
84 views

Simple Redis implementation in Rust

This is a very tiny implementation of Rust that uses redis serialization protocol (RESP). I implemented it as one of code crafters challenges. I have less than a few month experience in Rust, so it ...
Amir reza Riahi's user avatar
10 votes
2 answers
1k views

Beginner Rust Todo app

I am trying to use the practices that I have learnt from the rust book. Any advice is welcome. Please feel free to be as nitpicky as possible. ...
Doruk's user avatar
  • 203
3 votes
1 answer
165 views

RANDEVU - Rust crate implementing a simple algorithm I invented

I've created a simple algorithm, implemented it in Rust, and published it as a crate on crates.io. https://crates.io/crates/randevu My code seems pretty clean and idiomatic to me, but I'd like to know ...
TypicalHog's user avatar
3 votes
1 answer
204 views

Taking array of numbers, having a max weight, and distributing excess weight to ln max weight numbers

The goal is to take an array of numbers, have a max weight (saying 40%), and if any number above the max_num = sum * weight is present, remove the excess and ...
Bob Linux's user avatar
  • 131
3 votes
1 answer
97 views

Rust - idiomatic file search

I'm learning Rust. Could you share some tips for improving this code so it's more idiomatic and functional? I would prefer to stick to the standary library, and avoid unnecessary sorting or memory ...
valentin.milea's user avatar
3 votes
0 answers
63 views

Simple truss stiffness matrix calculator in Rust

I recently developed this calculator for some FEA homework i had. I'm still trying to familiarize myself with fundamental rust concepts like the ownership and borrowing. Pls let me know if there is ...
vvurd's user avatar
  • 31
6 votes
1 answer
145 views

Odometer in Rust

I am trying to implement an odometer in Rust. This should a be an iterator that yields items of type [u16; N] and it should be generic over const ...
RBF06's user avatar
  • 163
0 votes
1 answer
93 views

Handling default std::io::Error in Rust

I'm really new to Rust with less than a day of rusting. I'd like to know if the following code is ok or could it be written somehow better, and specifically, which would be the preferred way to handle ...
TrayMan's user avatar
  • 303
3 votes
0 answers
89 views

Rust ffi wrapper for barcode scanning library

I'm the maintainer of the zxing-cpp library, a barcode image processing library written in C++. I recently decided to invest in a Rust wrapper library/crate that is now on crates.io. It is basically a ...
axxel's user avatar
  • 147
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
5 votes
1 answer
455 views

High Performance Matrix Multiplication is not very high speed, why?

I would appreciate a review of the following Rust implementation of high performance matrix multiplication. After reviewing available literature, including Anatomy of High Performance Matrix ...
Ana's user avatar
  • 119
2 votes
1 answer
86 views

Rust Singleton Design Pattern using Lazy static initialization

In my current project there is a lot inter dependency between different structs, so instead of having Arc<Struct> as members for each of the dependent ...
Harry's user avatar
  • 429
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
6 votes
1 answer
303 views

AVX2 8x8 Float Matrix Multiply in Rust

I'm interested in a fast 8x8 32-bit float matrix multiply in Rust, assuming availability of AVX2. After learning about the AVX2 intrinsics, here is what I came up with: ...
Ana's user avatar
  • 119
9 votes
1 answer
288 views

Construct a performant sieve of Atkin in Rust

I have implemented the sieve of Atkin in Rust. It can find all primes till 1,000,000,000 in 4.5 s using 34.4 MiB on my 1.4 GHz machine. This is a direct implementation (with some optimisations made ...
tfpf's user avatar
  • 193
0 votes
2 answers
180 views

How to replace filter and map with filter_map? [closed]

The following sample code is for finding DIGIT_WORDS and their first occurrence in sentence line (Rust Playground) ...
Winston's user avatar
  • 119
5 votes
1 answer
91 views

Local Search Engine in Rust

I made a simple search engine using the xkcd API in Rust which turned out better than I'd hoped for! I decided to use tf-idf as a way to rank results, which I feel like has some room for improvement. ...
joeymalvinni's user avatar
6 votes
1 answer
83 views

Future struct that prints duration until it is Ready

I'm going through some exercises to learn about working with Pins. In the followinge example, I'm implementing Future for a wrapper around another Future. Calling poll on the wrapper will print the ...
c_seph's user avatar
  • 61
4 votes
2 answers
96 views

Make a config, that is periodically refreshed by a background thread, easily accessible to the rest of the program

I'm learning rust by implementing simple use-cases that are common and trivial in other languages. Recently, I decided to prototype a small component for retrieving some "config" from a ...
Black knight's user avatar
4 votes
1 answer
177 views

Custom derive macro to create getters and setters

To learn how custom derive macros work in Rust, I decided to create a simple derive macro to provide getters and setters for a given struct. It would be used like this: ...
Dornteufel's user avatar
2 votes
1 answer
133 views

Basic HTTP server implementation in Rust

I have made a basic HTTP server implementation in Rust. I have used frameworks like Actix-web in the past but the purpose of this code was learning and experimenting. I wanted to work as "low-...
O'Niel's user avatar
  • 197
5 votes
1 answer
162 views

Advent of Code 2023, Day 8 Part 1 - Beginner Rust Solution

Context I'm doing Advent of Code as a way of learning Rust, and have a working solution to Day 8, Part 1. This involves moving between nodes, starting at AAA and ...
F McA's user avatar
  • 53
5 votes
1 answer
279 views

A simple mmap(2) wrapper

I've written a wrapper for the mmap syscall. It's quite limited in functionality at the moment (there are lots of flags to support) but it's sufficient for mapping ...
haz's user avatar
  • 255
3 votes
1 answer
217 views

Using async websockets in Rust with tokio, rmp-serde and varint encoding

This is my first attempt at a real life app in Rust. I would mostly like to know if I am writing idiomatic Rust code, coming from Java and Python. I'll appreciate any pointers to improvements, though. ...
8192K's user avatar
  • 131
4 votes
1 answer
274 views

Parse two-digit numbers from text

I am participating in this year's Advent of Code for fun. Challenge 1.2 states: The newly-improved calibration document consists of lines of text; each line originally contained a specific ...
Richard Neumann's user avatar
4 votes
1 answer
68 views

Ringbuffer over a const generic Array in Rust

I implemented this generic ringbuffer over a const generic array with the usage of the MaybeUninit type. Is there something which is maybe unsound (having the lines ...
Lockna's user avatar
  • 143
6 votes
1 answer
203 views

My attempt at GNU echo in rust

This is my first post. I'm trying to learn Rust and I recently finished reading the Rust Book. For further learning I decided to try to reimplement some GNU core utilities in Rust. This is my approach ...
roocker's user avatar
  • 61

1
2 3 4 5
18