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
10 votes
1 answer
5k views

Binary trees in Rust: iterators

This is a follow-up to Basic binary tree manipulation in Rust, where Shepmaster suggested that I implement the Iterator trait for the binary tree. This ended up ...
wchargin's user avatar
  • 1,169
5 votes
1 answer
999 views

Basic binary tree manipulation in Rust

The goal here is to implement a basic binary tree with values only on leaves, with depth, mirror, and ...
wchargin's user avatar
  • 1,169
5 votes
1 answer
7k views

Simple TCP client in Rust

Here's a little command-line utility written in Rust that connects to a Denon AV receiver and sends a command, then receives the response. It's a simple TCP client that takes its command from the ...
squidpickles's user avatar
6 votes
2 answers
2k views

Jaccard distance between strings in Rust

The Jaccard distance between two sets is the size of their intersection divided by the size of their union. For example, the distance between {1, 2, 3} and ...
spike's user avatar
  • 163
2 votes
2 answers
197 views

Rosalind string algorithm problems

I've been starting to learn Rust by going through some of the Rosalind String Algorithm problems. If anyone would like to point out possible improvements, or anything else, that would be great. There ...
user673679's user avatar
  • 11.3k
5 votes
0 answers
853 views

Recursive factorial calculations in Rust

I am trying to calculate very large factorials. I am looking to speed it up as 10000! takes approximately a minute and a half. ...
Jared Mackey's user avatar
2 votes
3 answers
173 views

Project Euler 30 - Digit fifth powers in Rust

I am trying to move from Python to a systems programming language so this is a bit of a challenge for me. ...
Jared Mackey's user avatar
1 vote
1 answer
2k views

Monge Array - leftmost minimum for each row

This implementation is the result of solving exercise 4-6 "Monge Arrays" from the book Introduction to algorithms. Definition of a Monge Array: An m x n array A of real numbers is a Monge array ...
MAG's user avatar
  • 2,954
1 vote
2 answers
153 views

Euler problem 5

I am starting to learn Rust and it seems pretty awesome but it's way different than any C based language. I want to know how can I make this code more idiomatic and also how can I improve my solution ...
MAG's user avatar
  • 2,954
0 votes
4 answers
289 views

Evaluating a tic-tac-toe board using a C-style for loop in Rust

I program in C, and it's my favourite language. I've recently found Rust. I like their ideas. Sometimes looks like a weird mixture of C++ and Haskell, but overall it looks nice. The ...
user avatar
6 votes
2 answers
2k views

Merging an overlapping collection of intervals

I'm getting myself acquainted with Rust and decided to implement the classical overlapping intervals problem. Here is a statement of the problem: Given a collection of intervals, write a function ...
W.K.S's user avatar
  • 512
6 votes
1 answer
369 views

Implementing a van Emde Boas tree in Rust

I wanted to implement a van Emde Boas Tree in Rust, to start learning the language. Much of my implementation is derived from the pseudo-code on wikipedia, with the exception that empty subtrees are ...
zrneely's user avatar
  • 188
5 votes
2 answers
679 views

Netscape bookmark file generator

I started to learn Rust some time ago and I wonder if there is some way to write Rust code that is both concise and safe — in particular, avoiding unwrap(), casting ...
antoyo's user avatar
  • 153
9 votes
2 answers
6k views

Extracting the last component (basename) of a filesystem path

...
Sean Perry's user avatar
  • 1,179
7 votes
1 answer
249 views

Detecting two keys pressed in quick succession

My computer has been having this issue where when I press a key, two key presses get registered. The goal of this program is to detect the time delta between the two keys so that I can set an ...
gvl's user avatar
  • 171
12 votes
1 answer
409 views

Rust language tag implementation

language-tags is my first crate, it is hosted on GitHub and I uploaded it to Crates.io. It parses language tags like en-US into useful parts, like language and ...
Pyfisch's user avatar
  • 661
14 votes
1 answer
2k views

Simple cat in Rust

I'm learning Rust, from a Python background, and while I've used languages like C and C++ in the (distant) past, system languages aren't really my specialty. I would just like to know if my code is ...
Tom Carrick's user avatar
8 votes
1 answer
380 views

Recursively pop the last node from a singly linked list

I am exploring different ways of implementing a linked list in Rust as a learning project. In one particular place, I've got some code that works properly, but it makes multiple calls to unwrap--I am ...
GrandOpener's user avatar
34 votes
1 answer
1k views

Rust Brainfuck interpreter

I took the code from kostyas benchmarks for the Rust Brainfuck interpreter and tried to optimize it. There is also a discussion on Reddit about the poor performance of Rust in the Benchmark. Before ...
Pyfisch's user avatar
  • 661
4 votes
1 answer
1k views

Sieve of Eratosthenes Optimization in Rust

When I want to try a new language, I first try to write a fairly basic sieve of Eratosthenes project in said language. This is a very simple algorithm, with predictable results, and can even be ...
NuclearAlchemist's user avatar
4 votes
1 answer
205 views

Input/output for a simple Brainfuck interpreter

The following code comes from a simple Brainfuck interpreter I'm working on to learn the Rust language. Error handling is omitted for simplicity. It is tested on ...
toro2k's user avatar
  • 143
23 votes
1 answer
612 views

Wanted a cat. Got lolcat

Wanna learn Rust? Ya rly! I can haz FizzBuzz? No wai! Gimme /bin/cat then. But rustc say LOL! Must handle teh err0rz! Now iz ...
200_success's user avatar
5 votes
1 answer
91 views

Using parser_combinators to parse a string

I am playing with Rust, and am trying to write a simple parser. I need to parse the string: "0123,456789" into a stucture: ...
chemist's user avatar
  • 53
3 votes
1 answer
89 views

SICP Exercise 1.3: Sum of squares of two largest numbers out of three, Rust Version

The exercise 1.3 of the book Structure and Interpretation of Computer Programs asks the following: Exercise 1.3. Define a procedure that takes three numbers as arguments and returns the sum of the ...
Marcus Vinícius Monteiro's user avatar
6 votes
1 answer
196 views

General Fizzbuzz

I'm learning Rust now and created a program to solve the task General Fizzbuzz on Rosetta Code. For example, given: 20 3 Fizz 5 Buzz 7 Baxx where the first line ...
wei2912's user avatar
  • 1,223
7 votes
2 answers
1k views

Rust Guessing Game

Am I making good use of the Rust language and APIs? What can be improved? ...
sargas's user avatar
  • 245
2 votes
1 answer
631 views

Rust version of my C++ command-line tool

First program I've written in Rust (besides the demos in the tutorial site). I decided to start by converting my C++ command line tool to Rust. This is not necessarily a 1 to 1 conversion, but I've ...
glampert's user avatar
  • 17.1k
2 votes
1 answer
63 views

Differentiate simple expressions

This is the first program I have written in Rust and I would like to know what some Rust experts think of it. I must be doing some stuff wrong, such as breaking code style, etc. The code ...
Ben Ruijl's user avatar
  • 123
6 votes
1 answer
481 views

Bitcoin algorithm BIP0039: Mnemonic code for generating deterministic keys

This is an implementation of BIP0039 in Rust (I used python-mnemonic as a guide). I'd like my first Rust program to be critiqued. I would like to know if the program is structured correctly, if I've ...
leshow's user avatar
  • 163
3 votes
1 answer
343 views

Text formatting with embedded markup for terminal output

I'm learning Rust. I wrote the following library to format text and output it to terminal, so that the formatting markup is embedded with the string itself (looks similar to HTML4). I feel the code ...
Michael Pankov's user avatar
12 votes
2 answers
5k views

How can I find out why this Rust program to echo lines from stdin is slow?

Given the following Rust program: ...
mkaito's user avatar
  • 229
2 votes
1 answer
126 views

Sum of N primes in parallel-ish

Linq's AsParallel() call would be my normal way of doing something like this, but Rust hasn't stolen that just yet. This method has obvious shortcomings, but I'm ...
archer884's user avatar
  • 151
12 votes
1 answer
2k views

K-Means in Rust

I have implemented for learning purposes a simple K-Means clustering algorithm in Rust. For those who are not familiar: you are given N points, say in the plane, ...
Andrea's user avatar
  • 437
2 votes
1 answer
508 views

Chat console using Ruby and Rust

One of the exercises I like to program when learning a new language is a chat client for the console. I've programmed it in many languages (Perl, Python, C, C++, JavaScript, ...). One of the versions ...
francesc's user avatar
  • 171
7 votes
1 answer
203 views

Project Euler #11"numbers in a grid" in Rust

To learn more about Rust, I implemented Project Euler #11 "Numbers in a grid". Contrary to some people, I prefer not having the actual data grid in my code, so I put it in a file, which I read in the ...
Thomas Ahle's user avatar
37 votes
1 answer
2k views

Shift and merge numbers as in 2048 game code

I started to learn Rust last night. Given its parallelization capabilities, I thought a good starting point would be porting my C++ AI for 2048 to Rust. This is the function implementing the shift ...
Jonas Schäfer's user avatar

1
12 13 14 15
16