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
8
votes
0answers
565 views

Advent of Code 2018 day 15 - Naive Rust program

I solved the Advent of Code problems last year in Python, and I wanted to learn a new language this year, so I decided to write up Part 1 of on of the hardest problems from last year - problem 15 - in ...
7
votes
1answer
67 views

Rust Book's Chapter 8 - Text Interface

I recently finished chapter 8 of Rust's book, and below is my solution to the third exercise: Using a hash map and vectors, create a text interface to allow a user to add employee names to a ...
5
votes
0answers
29 views

after initial r*view here is a rewrite of my c++ timerqueue ported to rust

Purpose. Provides a background task queue so that code can ask for a function to be run at a specified point in the future. They indicate what to run (a closure) and when to run it (also a name just ...
3
votes
1answer
83 views

port of my c++ timer queue to rust

This is part of a larger c++ project that I want to migrate to rust (a pdp11 emulator). This is one of the gnarliest bits of the c++ code so I thought I would start with it - its also self contained ...
4
votes
0answers
38 views

Fast compression using a thread pool

This is my latest effort on RFC 1951 compression ( the widely-supported compression standard ) in Rust. It uses 2 extra threads to compute the LZ77 matches and the checksum in parallel with the ...
5
votes
1answer
148 views

Why is my MD5 implementation 35% slower than the md-5 crate?

I wrote a minimal implementation of the MD5 algorithm. Comparing to the established MD5 crate, the crate has a 35% better throughput than mine. I'd like to know why. In reviewing the crate's code (...
4
votes
1answer
48 views

An app that helps determine lands in a Magic: The Gathering deck

Good evening, I'm new to Rust and would like some help refactoring this small app I made so that it's more efficient, even if it may be unnecessary. Basically I'm trying to figure out better ways to ...
1
vote
0answers
20 views

RFC 1951 “Inflate” (de-compression)

My exploration of Rust continues. I'm quite pleased with the 2-step table lookup for decoding variable bit-length codes here, for some reason I found this tricky to work out, but now it's done I like ...
4
votes
0answers
62 views

Tar file utility - Rust

I've been working on building a Rust version of GNU tar following the spec here. As of right now, I've got the binary accepting a single argument, the path to the file/directory to tar, which is ...
6
votes
0answers
164 views

Character-based transitions (part of a lexer)

As part of my prep for the Code Review community-challenge (which looks like it will be Write your own programming language), I've been working on an LL(1) lexer generator in Rust. Yes, lexer ...
3
votes
0answers
28 views

Another Min Heap implementation

I am having a look at Rust, this is the first data structure I have tried to implement ( the standard library has a max-heap implementation, so this is a learning exercise ). ...
1
vote
1answer
44 views

Filtering a Vec of structs and creating new vector of Strings or strs in Rust

I'm working through the Rust book, and it has the following example of how to use the filter method on Iterators (source): ...
7
votes
1answer
149 views

Pig Latin Application in rust

Just finished an exercise in the Rust online book and I wanted to know if there is anything worth talking about in the code I wrote... if there's any mistake or optimization possible. Convert strings ...
4
votes
0answers
79 views

Implement a micro service in Rust

Last year I tried to implement a micro service architecture in Rust. It was asked as a homework question in an employment interview process to be completed in a few days. The imagined use case was a ...
6
votes
1answer
77 views

Basic raytracer written in Rust

I come from a fairly strong background of C and thought that this project would be a good way to get a handle on Rust. Right now, I have everything in one file because I wasn't sure the best way to ...
20
votes
1answer
8k views

Calculate mean, median, and mode in Rust

I'm learning Rust using The Rust Programming Language. I'm trying the assignment at the end of chapter 8 — Hash Maps. The task is: Given a list of integers, use a vector and return the mean (...
4
votes
1answer
113 views

Battleship Game Field Generator

Summary I have been playing with Rust for a couple of days, so I thought I would implement something rather simple. This code generates a random variation of board for well-known game of Battleship. ...
6
votes
0answers
94 views

Simple-ish Rust implementation of 'cat'

I've seen some other implementations of cat (even in Rust) on this site, but none attempted to completely implement the GNU cat CLI as far as I can tell. This version that I am developing is complete (...
1
vote
0answers
41 views

Nth Prime via Sieve of Erastothenes as iterator

I did the Nth Prime problem on exercism.io. Now I need feedback what can be done better / improved to make the most of rust. The code calculates the nth prime. I chose to provide the sieve of ...
3
votes
1answer
72 views

Rust multi-cliented TCP Server library

I am new to Rust, so I created a mini library/wrapper for creating multi-cliented Tcp Servers. This is a starter project for me to learn Rust. How the module works is a user can pass in a function or ...
2
votes
1answer
58 views

How do I shorten my Rust code to get integer values from regex named capture groups?

I am completely new to rust. My first rust code is simple text filter application for parsing log file and accumulating some information. Here is my code: ...
2
votes
1answer
49 views

Handling Rc pointers correctly in a parent/children tree

Needs A container holds two collections: Parent instances and Child instances; their items can be searched by name; A child can ...
4
votes
1answer
54 views

Smallest and largest palindromes

I am new to rust and this is a program that finds out the palindromes between a range. All tests have been passed but this program is really slow in finding the 4 digits Palindromes. This is an ...
2
votes
1answer
46 views

How could I modularize this poker card game in rust?

I'm learning rust by creating a simple card game program, with the usual stuff, ranks, suits etc. Currently I only implemented the card generation and a simple render function (not for future use). ...
0
votes
0answers
19 views

Rust Iterator repeat_each

repeat_each transforms an iterator by repeating each value count times. It should be equivalent to ...
4
votes
1answer
142 views

Getting a Future from a Vector and a function

I'm pretty new to Rust and to it's async/await model, and I'm trying to do something that looks like a specialized Haskell's traverse function. Given a ...
2
votes
1answer
49 views

changing values in a vector

I am looking to have a code review on this tiny repository. The code seems to work, but I am not sure if I have written it in idiomatic Rust. ...
8
votes
1answer
85 views

Brainf*** interpreter in Rust

I'm learning Rust coming from an intermediate background in Python. I've completed the first 8 chapters of the book and I wanted a project that would solidify the concepts I learned, so I made a ...
0
votes
1answer
52 views

Suggestions for beginner Rust code [closed]

I just stated learning Rust (again...), here is a short bit of code I wrote: ...
3
votes
1answer
97 views

Readability Check

I'm new to Rust and would like to know if my code is using the language well, if there are big improvements and if the code in general is rust-like. At the moment it feels very C. I haven't yet ...
2
votes
0answers
20 views
-1
votes
1answer
38 views

Return a default object unless you get Some( Ok() ) [closed]

Doing this Rustlings I find I'm unhappy with the code I wrote, ...
3
votes
2answers
630 views

Convert string to pig latin in Rust

I'm new to Rust and am working through the exercises found on the bottom of this page. The function below converts a string into pig latin. The requirements are as follows. Convert strings to Pig ...
5
votes
3answers
379 views

Interleave two sorted arrays

To learn Rust, I tried to write a function that takes two sorted arrays of integers and interleaves them into one longer sorted array. Is this approach ok? Have I made any mistakes? ...
0
votes
1answer
57 views

Simple math library in Rust

So, I've tried to make a simple math library in Rust. What do you think about it? ...
1
vote
0answers
44 views

Finite State Machine

I'm beginner in rust. I would ask code review of my finite state machine. Main feature : static (event, state and transition) support pushdown It is the first step, second step is to use macro ...
6
votes
2answers
107 views

Rust Novice's Tic Tac Toe

Introduction I am a Rust novice. So far, I have finished reading the first 15 chapters of The Rust Programming Language (a.k.a. the book). Here's my first big Rust project — Tic Tac Toe. ...
3
votes
0answers
61 views

Observer pattern over FFI

I'm trying to write up a cross-platform rust library (one, that will be used in iOS/Mac/Android dev etc.) It is based largely on concept's and code from Mozilla. One of the requirements I have is to ...
2
votes
0answers
57 views

Rust - LFU cache

I have implemented an LFU cache and I'm looking for ways to make my code more idiomatic. [dependencies] linked_hash_set = "0.1.3" ...
7
votes
2answers
270 views

Rust CSV Sorter Code Lookover

I am new to Rust, began learning a few days ago. I have written a simple csv_sorter based off of one I had written for a class previously. Everything runs fine and I have gotten my expected results. I ...
4
votes
1answer
70 views

HTTPS proxy server in Rust using the CONNECT protocol

I'm a Rust newbie. As a pet project, I decided to implement a simple multi-threaded HTTPS proxy server in Rust which uses the CONNECT protocol. I have tested the code below using my browser. ...
4
votes
1answer
41 views

Convert to different bases

Another code for exercism, It is to convert Vec of u32 from one base to another base. Please help to make it more idiomatic, Also if this type of question is welcomed here or not. ...
3
votes
1answer
74 views

Binary search in Rust

I am a newbie to rust and wanted to know if this code is following idiomatic rust or can be improved. ...
3
votes
0answers
17 views

Simple graphics library from Sparkle

The piston2d-graphics crate provides a trait, Graphics, which allows easy access to some graphics primitives. This would be a ...
3
votes
1answer
49 views

List and filter files in Rust

I'm learning Rust and looking for better/cleaner ways to list all file names that do not start with filter, given a pathname as ...
1
vote
0answers
37 views

Quick Sort in rust

I followed the Algorithms book implementation of quick sort. ...
4
votes
2answers
82 views

Rust Conway's Game of Life: struct Board(Vec<Vec<Cell>>)

What do you think of using struct Board(Vec<Vec<Cell>>)? It's nice that I can attach the Display trait, and just ...
2
votes
0answers
43 views

Create Graph With Eulerian Tour in Rust

Eulerian Tour is a list of nodes that has a specific way to traverse the graph: it starts at one node, traverses along every edge in the graph exactly once and returns to the starting node. Here is ...
0
votes
1answer
42 views

Unroll for loop as macro to make array unmutable

I wrote these lines of rust yesterday. It turns 27 bits from a 32 bit integer into a 3x9 byte array, but my gut feeling is this should be done without having a mutable variable ...
2
votes
2answers
76 views

Fibonacci iterator

I've implemented the following Fibonacci iterator: lib.rs ...

1
2 3 4 5
10