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
4
votes
1answer
38 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
0answers
17 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): ...
6
votes
1answer
117 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
104 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. ...
5
votes
0answers
72 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
37 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 ...
2
votes
1answer
54 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
57 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
43 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 ...
3
votes
1answer
47 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
39 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
126 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
47 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
49 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
93 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
37 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
19 views
0
votes
1answer
56 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 ...
2
votes
0answers
56 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" ...
6
votes
2answers
105 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
266 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
67 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. ...
2
votes
0answers
16 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 ...
2
votes
1answer
43 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 ...
2
votes
1answer
62 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
33 views

Quick Sort in rust

I followed the Algorithms book implementation of quick sort. ...
2
votes
0answers
42 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
69 views

Fibonacci iterator

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

Pairwise hamming distance for binary data with missing values

I just started learning Rust and my first project is a command line tool generating a pairwise distance matrix for binary data while ignoring missing values. The input files look like so: ...
1
vote
0answers
28 views

A function for batch backpropagation of weight errors in a dense neural network layer

I'm switching my neural network library over to using ArrayFire for performance. One of the features I am losing moving from ndarray is ndarray_einsum_beta, as such I need to write my own function to ...
2
votes
0answers
60 views

Yet another Fahrenheit and Celsius converter

Introduction I am recently learning Rust by reading The Rust Programming Language (a.k.a. the book). I have finished the first three chapters so far, and this is my attempt for the first exercise ...
2
votes
0answers
28 views

Traversing a tree with two types of nodes, while keeping track of all ancestors

I wrote code that stores an AWS Organization tree in a tree data structure in Rust. From the tree, I use a slightly modified preorder traversal algorithm to print all of the accounts in the ...
1
vote
0answers
29 views

JSONSchema validation implementation in Rust

I'm developing a Rust library that implements JSONSchema validation (Drafts 7 fully works at the moment). I have Rust-specific questions and concerns about my implementation. It works by compiling ...
1
vote
0answers
67 views

Basic Rust HTTP request as a learning exercise

For work, we have to use Atlassian Jira, which is depressing. To make my life a bit easier, I decided to write a cli application to get ticket summaries, and I thought it would make a good first ...
1
vote
0answers
70 views

Implementing A File and Directory Traversal Iterator in Rust

Background Traversing the file hierarchy, going through files and sub-directories from a directory, is a quite common task when doing file system search operations of some sorts. I have already ...
3
votes
0answers
80 views

Function composition in rust

In rust fp-core crate there is a compose function, but it is very limited for my liking. So I made a macro which uses the function composition syntax of Haskell. I would like to know why fp-core didn'...
3
votes
0answers
49 views

Simple beginner Rust CLI file reader that prints to stdout

Q: Am I approaching writing idiomatic Rust code correctly? Hi CodeReview, I'm a beginner Rustacean coming from Python going through Rust books (The Rust Book, Rust in Action). A lot of the beginner ...
1
vote
0answers
24 views

Filtering two dimensional vector in Rust

Recently started writing more rust code and interested in how anyone may get around using .clone() within a map of a referenced data structure. I've included a test ...
0
votes
2answers
145 views

Largest product in a grid: Project Euler 11

Project Euler 11 — Largest product in a grid: In the \$20 × 20\$ grid below, four numbers along a diagonal line have been marked in red. ...
3
votes
1answer
45 views

Generic Cache struct

I've came up with the following implementation of a very simple cache: ...
15
votes
2answers
2k views

Web crawler in Rust

I am learning Rust. I have written a web crawler that would scrape all the pages from my own blog (which is running on Ghost) and would generate a static version of it. Because of this, I'm not ...
2
votes
0answers
25 views

Rotational Symmetry Indexing in a 1D “Square” Array

I managed to find a way to rotate a slice in-place (previous question on SO). The slice is linear, but represents a 2d square of elements. Is this approach efficient? Please check the previous ...
3
votes
0answers
39 views

Conjugate gradient method for a sparse matrix

I am very new to Rust. I have written a conjugate gradient algorithm function for CsMatrix structure from nalgebra ...
2
votes
1answer
84 views

Quick sort algorithm in Rust

I have written this Rust code to implement the quick sort algorithm. Could you review it and tell me if it is idiomatic or not? Especially about my use of the slices? ...

1
2 3 4 5
10