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

Inversion of control in Rust

I'm working on my first Rust project of any particular size, a rudimentary IRC bot. So far I've found solutions to most of the problems I've encountered, but something I'm now getting tangled up in as ...
4
votes
1answer
193 views

A concurrent lock-free Linked Queue implementation

Recently I've been learning about concurrency/parallelism and I decided to implement the Michael&Scott lock-free Linked queue (PDF) as practice. I'm not entirely sure how to test this data ...
2
votes
0answers
71 views

Pong Implementation using Rust SFML

Getting my feet wet with Game Development, and was wanting to see where I could improve in my usage of Rust as well as Game Development concepts. ...
2
votes
0answers
18 views

Prototype of a scanner/tokenizer for Bitmap Distribution Format parser

Instead of the obvious decision, parsing using given std::io::Lines/std::io::Bytes or crates like nom, I decided to explore ...
7
votes
1answer
668 views

How can I make my error handling more idiomatic in Rustlings exercise "from_into"?

I've got a working solution to the Rustlings from_into exercise (i.e. the code compiles and all the tests pass). The task required that I implemented the From trait ...
7
votes
2answers
211 views

Dijkstra's implementation in rust

I would like to get any feedback about my implementation of Dijkstra algorithm in Rust following this youtube video. Please be aware that this my first code in Rust as well as my first Dijkstra ...
6
votes
1answer
73 views

Buffered and unbuffered cat(1) implementation

I reimplemented cat(1) for fun. I followed the Open Group Base Specifications (Issue 7, 2018 edition), not the GNU variant and its command line arguments. Buffered ...
5
votes
1answer
152 views

Largest Prime factor (Project Euler in Rust)

I've been working on my Rust a bit and want to know how idiomatic my rust code is for the following Project Euler problem: ...
5
votes
1answer
461 views

Dictionary implementation in Rust

This is an implementation of a dictionary (hash map) in Rust. It is loosely based on Python's dictionary implementation, using the same "random" probing and capacity/size management. Does it ...
7
votes
1answer
253 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
36 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
136 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
55 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 ...
4
votes
1answer
65 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
32 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
139 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 ...
3
votes
0answers
204 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 ). ...
6
votes
1answer
103 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 ...
2
votes
1answer
1k 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
307 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 ...
5
votes
1answer
392 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
124 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
134 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
839 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
208 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
73 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
84 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
173 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). ...
4
votes
1answer
337 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
109 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. ...
0
votes
1answer
59 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
135 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 ...
-1
votes
1answer
43 views

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

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

A service that posts JSON to a server and works with responses

...
0
votes
1answer
123 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
91 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 ...
3
votes
0answers
79 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
78 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
197 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. ...
7
votes
2answers
292 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
687 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. ...
3
votes
1answer
79 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
0answers
20 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
298 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 ...
4
votes
1answer
268 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. ...
1
vote
0answers
95 views

Quick Sort in rust

I followed the Algorithms book implementation of quick sort. ...
1
vote
0answers
48 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
65 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
156 views

Fibonacci iterator

I've implemented the following Fibonacci iterator: lib.rs ...
3
votes
2answers
147 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 ...

1 2 3
4
5
13