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
20 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 ...
4 votes
1 answer
66 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 ...
4 votes
1 answer
757 views

Rust publish/subscribe channel library

I've written a simple multiple-sender multiple-receiver channel, but I'm unsure if my approach is the best way to do this. I'm not using multi-threaded primitives but instead wrapping around std's ...
2 votes
1 answer
226 views

Efficient Connection Pooling in ODBC-MSSQL with Rust (odbc-api)?

I want to connect to MSSQL using ODBC (odbc-api) at the beginning of my server application created with hyper.rs. I want to have a connection pool and obtain a connection within each request, which ...
1 vote
0 answers
47 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 ...
4 votes
0 answers
65 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 ...
2 votes
0 answers
51 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 ...
4 votes
1 answer
263 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 ...
3 votes
0 answers
65 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 ...
4 votes
1 answer
60 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 ...
5 votes
3 answers
664 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 (...
4 votes
1 answer
70 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 ...
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. ...
4 votes
1 answer
259 views

Console Tic-Tac-Toe game in Rust

While having experience with other languages I only recently started learning Rust and I was hoping to get some feedback on my little beginner project, especially regarding style (stuff like too many ...
5 votes
1 answer
274 views

Doubly linked list in Rust using raw pointers

I am practicing Rust by writing doubly linked list using raw pointers, Box<node> to allocate data on heap, Box::from_raw ...
4 votes
1 answer
331 views

Yet another Fahrenheit and Celsius converter

Introduction I am recently learning Rust by reading The Rust Programming Language (a.k.a. the book). I have finished the first three chapters so far, and this is my attempt for the first exercise ...
3 votes
1 answer
203 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 ...
3 votes
1 answer
114 views

RANDEVU - Rust crate implementing a simple algorithm I invented

I've created a simple algorithm which I've implemented in Rust and published it as a crate on crates.io. https://crates.io/crates/randevu While I do think my code is pretty clean and idiomatic, I ...
3 votes
1 answer
96 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 ...
3 votes
0 answers
58 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 ...
6 votes
1 answer
82 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 ...
6 votes
1 answer
144 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 ...
3 votes
1 answer
391 views

Cosine similarity calculation in Rust, which is slower than NumPy

I'm running this in release mode. Currently, the following function takes around 6.7 seconds to run on my computer vs 3.7 seconds on Python. I know that Numpy is just calling to C, but I'm trying to ...
0 votes
1 answer
87 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 ...
3 votes
0 answers
85 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 ...
4 votes
0 answers
105 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 ...
2 votes
1 answer
82 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 ...
4 votes
0 answers
60 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 ...
4 votes
1 answer
99 views

Buddy - Algorithm in Rust

I wrote my first code in Rust and decided to recall the buddy algorithm, which I suggested at work for our embedded software. I hope you can give me some advise on things like: How to make it safe (...
5 votes
1 answer
431 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 ...
6 votes
1 answer
162 views

Mandelbrot Set image generator in Rust

I'm learning Rust, and as-is tradition, I'm starting out with a Mandelbrot Set explorer as my first project (although, it just produces images so far). When run, it just creates and writes an image to ...
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 ...
2 votes
1 answer
101 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-...
5 votes
1 answer
83 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. ...
6 votes
1 answer
296 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: ...
9 votes
1 answer
278 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 ...
0 votes
2 answers
172 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) ...
4 votes
1 answer
121 views

C# wrapper that binds to Rust FFI, for the purpose of running CavalierContours functions in Unity

I have attempted to write c# bindings for a Rust library. I have never worked with unmanned code / languages before. Superficially this code does work with no apparent bugs or memory leaks. I want to ...
3 votes
1 answer
129 views

A Spatial Hash View: Store references to spatial data so it can be used for performant broad phase collision detection

I have created a non-owning view of some spatial data that organises the data into cells. The data is split into a grid of cell size 100, and the key to the ...
4 votes
1 answer
145 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: ...
5 votes
3 answers
679 views

Temperature unit conversion in Rust

Below is a simple Rust program which inter-converts temperature between the Celsius scale and the Fahrenheit scale. It takes two inputs: scale referring to the temperature scale of the next input the ...
4 votes
1 answer
66 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 ...
5 votes
1 answer
158 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 ...
5 votes
1 answer
272 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 ...
3 votes
1 answer
163 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. ...
6 votes
1 answer
200 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 ...
1 vote
1 answer
56 views

Idiomatic way to filter a `Vec` of version identifiers to only include latest version for each minor release?

I have a Vec<String> of all available versions of a particular piece of software (Godot), named VERSIONS in code below, ...
3 votes
0 answers
47 views

Assign unique identifiers to binary matrices using a binary tree

Context I want to build a transposition table where the game states are binary square matrices which size MATRIX_SIZE is known at compile time. Rather than storing ...
2 votes
1 answer
508 views

Quickly create polars data frame from 2D ndarray

I am sampling from m normal distributions n times each, and storing the samples in a 2-dimensional ndarray. I then need to turn this into a polars dataframe as I need to add some string columns and do ...
3 votes
1 answer
157 views

Get HTTP status of many URLs

I'm brand new to using rust, so please bear with me. I'm trying to write a rust program which takes two arguments: A URL, and a wordlist. This wordlist has the following contents, and is several ...

1
2 3 4 5
18