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

sharing an Arc<tokio::sync::Mutex>> with double closure [closed]

When using Arc<tokio::sync::Mutex> and passing an arc into double closures, is it good practice to clone the "challenge_ref" here. Without the clone ...
2
votes
0answers
22 views

Rust blog backend in Rocket and Diesel, lots of clones

I have a small blog backend in Rust with Rocket and Diesel on Postgres. It reads and writes to and from the database fine, but to get to where it is I used a lot of ...
3
votes
0answers
35 views

Building a GTD Productivity App Designed through Test Driven Development (TDD)

First, thanks so much for looking at my code. Over the past decade, I have tried every task management apps imaginable. I finally realized that the only way I would ever find my perfect productivity ...
6
votes
2answers
95 views

Rust beginner implementing some sorts

I'm starting to learn Rust. After reading through chapter 13 of the Rust Book, I've gone and implemented a handful of sorting algorithms for practice with the language. Would love to learn some more ...
2
votes
1answer
34 views

New to Rust: Hangman game

I decided to try my hand at a Hangman game to familiarize myself a bit with the language. ...
1
vote
0answers
37 views

Idiomatic Rust matches with pattern guards

I'm quite new to Rust, and am working on a virtual machine image decompiler. I have some working code that uses match to check opcode numbers, but it doesn't feel ...
3
votes
0answers
72 views

A wrapper library for League Of Legends API

I'm a new Rustacean, decided to make a wrapper for the LeagueOfLegends API. Focus is on simplicity, being able to make any API call with a simple function. I have not finished all functions however it'...
4
votes
1answer
61 views

Convert array of u32 to Vec<u8> in Rust

In Rust, I want to take an array of u32 values, convert each to four bytes in big endian, and concatenate them to yield a ...
4
votes
1answer
82 views

LeetCode: FloodFill Rust

Hi I'm implementing a few leetcode examples in Rust. https://leetcode.com/problems/flood-fill/ (looks to be same question as LeetCode: FloodFill C#) The input is one matrix, a position and its new ...
2
votes
0answers
27 views

How can I simplify my nom parser?

I'd like a recommendation on how I can improve the function unquoted_string below - specifically is there a better way to combine the parsers I have to achieve the ...
4
votes
1answer
201 views

Rust Beginner: flatten nested matches

This is how I implemented the guessing game - chapter 2 of the Rust book: https://doc.rust-lang.org/book/ch02-00-guessing-game-tutorial.html ...
2
votes
0answers
41 views

design to send multiple type http request

I have to send multiple HTTP requests where their payload will be different, type will be different, headers will be different, URL will be different etc. The code I have right now is ...
3
votes
1answer
130 views

Rust shortest way to find the maximum product of a fixed length substring

I'm trying to code in a Rust a function, that gives the maximum product of adjacent digits. So given the string 123456789, with 3 adjacent digits, the maximum is <...
4
votes
1answer
83 views

Would anyone like to view my command line hangman game?

Id like feedback on my code. Specifically the parts where i use graphemes. I use cloned strings because the grapheme functions eat my strings. But feel free to comment about anything else that looks ...
3
votes
0answers
28 views

Metronome in Rust, Audio Handling and Threading

for learning purposes (and I found it kinda useful), I built a very basic command-line based metronome in rust. It's the first actual smaller project I built in rust. It consists of 4 source files. ...
3
votes
1answer
176 views

Memory/Time usage on substring search code

I have implemented a substring search, which works as expected and provides the right output. On some edge cases tho, I get either Memory or Time limit exceeded because: the string length is too big ...
3
votes
0answers
31 views

Performance and abstraction questions re: scraper for carfolio.com

I'm a new Rust programmer, primarily coming from Ruby experience. I started working on a small project to scrape vehicle specifications from https://carfolio.com I chose to write it in Rust and ...
2
votes
1answer
40 views

Tokenizer FSM in Rust - better way to do match statements?

I'm learning Rust and have decided to code up a toy YANG parser as an exercise. In case it's relevant, I mainly work in C and Python. While working on the tokenizer/lexer, I tried to make it Rust-y, ...
1
vote
1answer
88 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
68 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
30 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
9 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 ...
4
votes
1answer
121 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
160 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
56 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
0answers
62 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
53 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
96 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
32 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
94 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
41 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
57 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
22 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
73 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
32 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
85 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 ...
1
vote
1answer
54 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
165 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
1answer
123 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
106 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
48 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
89 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
60 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
54 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
60 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
52 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
27 views

Rust Iterator repeat_each

repeat_each transforms an iterator by repeating each value count times. It should be equivalent to ...
4
votes
1answer
158 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
51 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
55 views

Suggestions for beginner Rust code [closed]

I just stated learning Rust (again...), here is a short bit of code I wrote: ...

1
2 3 4 5
11