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
1 answer
59 views

Prime sieve in Rust

Using Sieve of Eratosthenes, I created a function that returns a vector of primes up to given limit. ...
manungsa's user avatar
0 votes
1 answer
53 views

thread creation and termination design pattern in rust

I am new to rust and come from a Java background. Currently I'm trying to imitate the java methodology of thread creation using ...
Harry's user avatar
  • 319
2 votes
1 answer
32 views

Create bash ranges from integer sequences

The following code is meant to generate ranges from arbitrary integer sequences and print them in a bash-like syntax: main.rs ...
Richard Neumann's user avatar
5 votes
1 answer
92 views

Learning rust by writing a calculator

As the title suggests, I'm learning rust. My go to starter project when learning a language is to write a calculator. It's relatively simple, but complex enough that you will need to utilize many ...
ruinedme's user avatar
2 votes
1 answer
62 views

Parallelization of the tick function in a Game of Life simulation using Rust and Python (+ NumPy)

I've been writing a small Rust module recently with the sole purpose of speeding up my Python program, which is a Conway's Game of Life simulation. The function written in Rust is called from Python ...
chubercik's user avatar
  • 121
1 vote
1 answer
82 views

Complex numbers implementation in Rust

I am learning object oriented programming in Rust. I created my own struct for complex numbers. Could you please review and answer my questions: Is it possible to implement C++-like default ...
mascai's user avatar
  • 289
3 votes
1 answer
72 views

Deciding between rust-specific and conventional syntax

I am learning Rust by implementing a series of simple modules which I tend to use a lot in other languages. One of them describes simple methods done on intervals (union, intersection, etc). Here I ...
av_matat's user avatar
2 votes
2 answers
101 views

Rust: Looping over every file in a directory, collecting and modifying filenames and metadata

I'm building a simple blog with Axum and Rust, mainly to practice Rust. I find myself finding working solutions to the things I want to do, but I don't like the end result of my code, it doesn't feel ...
EBjor's user avatar
  • 23
1 vote
2 answers
78 views

Sort by parity in rust

I am learning sorting in rust. I want to sort vector as such that even numbers go first My code is OK. But can it be improved (I want to use sort function)? ...
mascai's user avatar
  • 289
0 votes
2 answers
57 views

Checking which programs are used for scripting

I have a directory where there are some script files, some binary files, and some subdirectories. I have tried to write a program which gets names of all files in directory, and excludes if they are ...
rnso's user avatar
  • 241
5 votes
3 answers
610 views

Merge Sorted Array in Rust

I was solving this task https://leetcode.com/explore/learn/card/fun-with-arrays/525/inserting-items-into-an-array/3253/ The main idea is to merge two sorted arrays (more details in the site) Example: <...
mascai's user avatar
  • 289
3 votes
0 answers
147 views

Tauri/Rust small program to upload files with use of threads and openssh

First time I'm using Rust in one of my programs and I feel a lot can be improved. I don't have any colleagues / friends that already used Rust so this is the only way to get some validation that it's ...
Jeroen Claessens's user avatar
5 votes
1 answer
60 views

Checking if a graph is fully connected

After reading the rust book for some time I decided to create my first program which implements a graph. There are a few things I was wondering about, such as if the file structure is appropriate (the ...
Jannes Braet's user avatar
4 votes
1 answer
86 views

Find the longest palindromic subsequence - Using a hashmap in Rust

This is a leetcode question which I wanted to solve using Rust as I'm learning Rust at the moment. I would appreciate some feedback on how to write it idiomatically. Link to the question: https://...
bluprince13's user avatar
4 votes
1 answer
63 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 ...
arcadeperfect's user avatar
3 votes
1 answer
55 views

End to End testing of user interaction in Rust

I am interested in any kind of possible improvement to this method of testing a Rust program with user interaction in an end-to-end manner (simulating user input and asserting a certain program output ...
Caridorc's user avatar
  • 27.4k
7 votes
1 answer
316 views

piglatin exercise in rust

This is my attempt to make the exercise suggested at the end of this chapter of rust's official tutorial ...
JoulinRouge's user avatar
4 votes
1 answer
143 views

Fahrenheit <=> Celsius converter in Rust

It's one of the tasks suggested in the Rust Programming Language book by Steve Klabnik and Carol Nichols, and to a complete Rust newbie like me, figuring out converting scale from ...
razorramon's user avatar
2 votes
1 answer
69 views

First attempt using Rust, to create a simple API backing onto a JSON file

I'm trying to learn Rust, and have taken a stab at it by create a REST API, that stores the data in a local JSON file. Before I get deeper into things I'd like some feedback on if I'm doing things in ...
TMH's user avatar
  • 499
7 votes
2 answers
1k views

Calculating the median and mode of a list of integers

Going through the Rust book for the second time as I've been wrapped up in Typescript for a while and I want to build a personal project in Rust. In chapter 8.3, there's an exercise: Given a list of ...
Lewis Farnworth's user avatar
9 votes
2 answers
945 views

Binary adder implemented in Rust

I implemented a ripple carry adder in Rust. The function takes and outputs strings of 1s and 0s. How can I improve this ...
theonlygusti's user avatar
3 votes
1 answer
168 views

Fast approximate sin/cos function in Rust

Over the past month or so, I’ve been trying to create an extremely fast, platform agnostic, auto-vectorizing sin/cos function for fun. I initially started with sleef-rs’s fast sin function, and ...
burgerdude's user avatar
2 votes
1 answer
64 views

Rust implementation of Hangman

I created a rust implementation of hangman as a command line version. The user can enter characters to find out the desired word. I really appreciate any helpful comment which highlights how I could ...
user6475988's user avatar
1 vote
1 answer
65 views

Dynamically serializing a subset of struct fields to JSON in Rust

I have a struct which, depending on options, I want to serialize to json with different subsets of the fields. However, my existing solution leads to a large amount of hard-to-maintain boilerplate. I'...
Kofthefens's user avatar
5 votes
1 answer
113 views

Data Oriented Raytracing In a Weekend in Rust

I've been learning about Data Oriented Programming, and when trying to implement this simple Raytracer, I decided to do it in this manner using Rust. This is also in the context of an optimisation ...
TOOL's user avatar
  • 51
3 votes
1 answer
63 views

HTTP server stress tester in Rust

I wrote the following HTTP server stress tester in Rust. My actual goal was to write an efficient template for writing load testers, so I can swap out the inner loop to do e.g. requests to a Redis ...
eof's user avatar
  • 193
4 votes
1 answer
65 views

Implement Seek on /dev/stdin file descriptor in Rust

Problem: In order to be able to use the arrow crate's infer_file_schema function with input piped to ...
Cornelius Roemer's user avatar
3 votes
1 answer
107 views

Find factor pairs of an integer in Rust

I'm trying to efficiently generate all pairs of factors of a number n. For example, when n=27, the factor pairs are (1, 27), (3, 9), (9, 3), (27, 1) The order in which the pairs are found is not ...
Bram's user avatar
  • 93
3 votes
1 answer
83 views

RUST-based weather logger. Makes HTTP request to get a JSON and write to .csv

I've recently attempted to get into rust. I thought I would try convert my weather logging app from python to rust to maybe save some CPU cycles on my little Raspberry Pi. I have a little ESP8266 with ...
Biscuit's user avatar
  • 33
0 votes
0 answers
18 views

Smoothed Particle Hydrodynamics in Rust - Rev 2

So, I've already had this reviewed once here and having implemented the changes (save multithreading), I was wondering what people thought now. A summary of the changes: I've fixed the broken attempt ...
ScottishTapWater's user avatar
1 vote
2 answers
47 views

Implementing a function that takes in 2 collections of strings and compares them as if they are unordered in Rust

I'm new to Rust and I would like to implement a function to compare 2 collections of strings. The function should compare them as if they are unordered. In Python, I would implement something like ...
James's user avatar
  • 13
0 votes
0 answers
80 views

Vector with small internal buffer

I implemented a vector with small inline storage to avoid allocation when the size is small. I am still new to Rust, so I have no idea how good this is. I tried to match ...
Ralender's user avatar
2 votes
1 answer
77 views

Idiomatic builder pattern in Rust

I have a couple of questions regarding how builder should be implemented idiomatically in Rust when it's necessary to call its parts depending on some flags. Here's my take on three different designs ...
sukhmel's user avatar
  • 213
1 vote
1 answer
80 views

DFS Maze Solver

I am new to Rust Programming so I decided to implement a Maze Solver using DFS. I was wondering if there is any way to optimize this code further ...
Ben's user avatar
  • 11
2 votes
1 answer
55 views

Smoothed Particle Hydrodynamics in Rust

So I'm simultaneously learning both Rust and Smoothed Particle Hydrodynamics. I've been using this video from AMD as a reference and the provided smoothing kernels. At this stage, I've not optimised ...
ScottishTapWater's user avatar
1 vote
1 answer
103 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 ...
Jage's user avatar
  • 111
2 votes
1 answer
73 views

Rust - implementation of multiple type of graphs with shared code

I am trying to improve my Rust coding skills. One thing which I find hard to tackle is how to shift from a polymorphism you can observe in e.g. Python to sth. similar in Rust? Let me give you a ...
qoqosz's user avatar
  • 123
3 votes
1 answer
68 views

Rust Book Chapter 8 - Text interface for employee management

Using a hash map and vectors, create a text interface to allow a user to add employee names to a department in a company. For example, “Add Sally to Engineering” or “Add Amir to Sales.” Then let the ...
mrchocoborider's user avatar
4 votes
3 answers
119 views

Improving efficiency of Rust algorithm ported from Python generator

I'm learning Rust by solving ProjectEuler problems. To this end, I am trying to port a solution to problem 88 (link) in Python that heavily relies on generators to Rust (which doesn't have generators)....
Bram's user avatar
  • 93
6 votes
2 answers
128 views

Programming Language Source Lexer

I have a lexer (program that turns source code into tokens) written in Go that I am re-writing in Rust. The lexer should take in a sequence of tokens, generally different special characters, integers, ...
John Allison's user avatar
3 votes
1 answer
66 views

rust sort numbered directories (non-lexicographical)

I am very new to rust and have been reading up and playing around to get a better understanding. I was trying to replicate a small task that I have done via bash scripting before, as a way to ...
Kyle Price's user avatar
1 vote
1 answer
117 views

Text to image steganography

This simple implementation hides text secrets (S) in images by manipulating the least significant bits (lsb) on Pixels. How it works When encrypting I take a three pixel "chunk" for each ...
チーズパン's user avatar
4 votes
2 answers
121 views

Produce randomly-generated pronouncable names

...
D0SBoots's user avatar
  • 143
0 votes
0 answers
33 views

Procedurally generated 2D grid module implemented in Rust

I've got this Rust module which implements a procedurally-generated module that operates on a 2D grid (implemented as a vector of vectors). However, I'm not sure if its idiomatic Rust or how efficient ...
Aspect11's user avatar
6 votes
1 answer
179 views

Rust: Splitting a mutable slice into disjoint, but non-contiguous subslices

For some context, this is inspired by my attempt to solve this SO question. I have a mutably borrowed slice representing a 2D array, and I want to split the borrow such that I can access all the rows ...
FZs's user avatar
  • 163
1 vote
1 answer
89 views

Rust state-machine lexer

I tried implementing a lexer in rust that peeks ahead at the next character and makes a decision based on that. However, i am told that this is bad practice, and instead i should be using finite-state-...
xxxxxxxxxx's user avatar
1 vote
1 answer
67 views

Finding the Median and Mode of a slice in Rust

Overview I’m trying to learn Rust, so I’m reading The Rust Programming Language. At Chapter 8, there was a task to write a program that calculates the median and mode of a bunch of numbers. I ...
schuelermine's user avatar
3 votes
0 answers
172 views

Generic Monte Carlo Tree Search implementation in Rust

I'm working on a project where I need a strong AI for a combinatoric game, and decided to go with Monte Carlo Tree Search because the specific game will be original to the project - no good heuristics ...
crass_sandwich's user avatar
0 votes
1 answer
88 views

supporting unicode in rust lexer

I am working on a lexer in rust. It has been through many different iterations, going from iterating over a Vec<char> to ...
xxxxxxxxxx's user avatar
0 votes
0 answers
83 views

What do you think about this code for functions that take both pool and transaction?

I'm trying sqlx for the first time these days, sorry if this is a dumb question. I'm writing a function that I want to take both PgPool and ...
Fred Hors's user avatar
  • 183

1
2 3 4 5
16