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

Application uniqueness and unilateral IPC on Unix

This program Detects application uniqueness, if the application is a unique/primary instance, it launches a server, otherwise a client over a Unix domain socket. Client will send a message that will ...
7
votes
1answer
45 views

Rust echo implementation that supports command line options

I rewrote echo from the manpage to learn Rust, and got the following: ...
5
votes
1answer
62 views

Educational implementation of SHA256 in Rust

A few weeks ago I decided to have a look at the Rust programming language. After a few standard exercises I chose to try to implement the SHA256 hashing algorithm, because why not. The algorithm's ...
4
votes
1answer
47 views

99 beers song in Rust

I'm learning Rust. I find it sometimes confusing when compared to other programming languages, especially when dealing with strings and slices. Her's an implementation of the 99 beer song that I've ...
4
votes
1answer
85 views

Sanitize and build data structure from Consul configuration

I have a piece of working code that takes some strings from Consul configuration exports, sanitizes them a little and converts them into valid json and/or hocon structures. While I am iterating over ...
2
votes
1answer
54 views

Rustacious way of checking if string ends with any suffix from a selection

What's the best way to check if a String ends with any of multiple suffixes in Rust? I have a working, naive solution: ...
3
votes
0answers
41 views

Caching image thumbnail web-application based on rocket

This is my first rocket web-app. It serves images from a directory and thumbnails from a sub-directory. if no thumbnail is found for an existing image it is created on the fly. Before I launch this ...
4
votes
1answer
38 views

Solving the knapsack problem with user provided input

This question was given in my college assignment to be done in C. After doing that, I rewrote the program again in rust. I come from a C/Python background and this is my first rust program. Please ...
4
votes
1answer
117 views

Converting a binary string to hexadecimal using Rust

Once again, I am reinventing the wheel here to understand the fundamentals of rust. In a previous question I requested feedback on my function that performed a hexadecimal to binary conversion. In ...
1
vote
0answers
34 views

List files and folders in current dir with special handling for tty

I want to write a custom ls command to learn rust. This is what I've done as for the version 1.0. This display files and folders in a cyan or white if it's on a ...
4
votes
1answer
54 views

Idiomatic quadtree implementation in Rust

I am learning Rust, coming from a Java background, and I was hoping to get some critique on my simple QuadTree implementation in Rust. This is as a learning exercise for me. Are there tips on how to ...
4
votes
1answer
60 views

Converting a hexadecimal string to a binary string using Rust pattern matching lookup

I am getting started in Rust, and as a part of my first exercise, I decided to write a small program that converts a hexadecimal string to a binary string using a pattern matched lookup. I would ...
6
votes
1answer
701 views

Rust Torrent Parser

I wrote a simple Torrent file parser. The following program accepts a file and builds a Torrent structure based on the contents on the file. If the file is invalid, the app crashes (as intended). It'...
2
votes
3answers
105 views

15 line Rust program, which writes the numbers 1 to N to a file

I have this simple Rust program, which creates a file called numbers.txt and writes the numbers 1 to N (N is here 10000000) to it, separated with newlines: ...
3
votes
1answer
82 views

Toy Expression Interpreter

I've just started learning Rust (coming from Haskell) and decided to test a toy expression interpreter. Code: ...
1
vote
0answers
52 views

Fast text search in Rust

I have a large file that I want to search for text as fast as possible. There is not a memory contraint, so I am loading the entire file into memory so that I can use the rayon parallelism crate in ...
1
vote
1answer
52 views

Rust program, which reads, processes, and writes a file

I'm making a small program to benchmark Rust's performance compared to some other languages. The idea I came up with, was to take a file (with the numbers 1 to 10000000 written to it in separate lines)...
1
vote
0answers
72 views

AES encryption/decryption in rust: performance and best practices

I wrote a small rust library available on github that can encrypt/decrypt a 16 bytes block using either 128, 192 or 256 bit passwords. This implementation is tested with the test data provided in the ...
3
votes
0answers
71 views

Implementation of a hash table using safe Rust

I just finished reading the rust book and I am doing lots of little projects to practice and try to get better at writing idiomatic Rust. One of them involves implementing a hash table (I find it's ...
1
vote
1answer
42 views

Train reservation system in Rust as my practice

Abstract I am a beginner of Rust language. As my practice I want to create simple train reservation system. I know little about the "best practice" in Rust, so I want some advises in my code. In ...
4
votes
1answer
77 views

Most idiomatic way of declaring a deck in Rust

I'm new at Rust and I'm trying to implement a cards' deck on Rust, I'm trying to use most idiomatic code I can, but since I'm new at this language, I'd like to hear advice from more experienced ...
4
votes
2answers
123 views

Number to vector of its digits

There is a function that returns digits as vector of given number. Is it idiomatic way to solve this problem in Rust? Can you suggest more concise solution? ...
4
votes
0answers
92 views

Brainfuck interpreter written in Rust

I'm learning Rust at the moment by reading the book (currently on chapter 17). I wrote this simple Brainfuck interpreter, because I think that it's always a fun exercise. The program consists of ...
2
votes
0answers
32 views

Command String Parser

I'm working on a library that, in essence, splits a string at whitespace, with extra rules: Consecutive whitespace is collapsed, and trimmed at the start and end. Whitespace wrapped in quotes is not ...
1
vote
0answers
50 views

Rust book ch 13 Closures + HashMap exercise

So the exercise is as follows: Try modifying Cacher to hold a hash map rather than a single value. The keys of the hash map will be the arg values that are passed in, and the values of the ...
5
votes
1answer
70 views

Rust code of a tree fractal

I just picked up Rust recently and this is my first program (longer than 10 lines at least) so I'm looking for constructs that are more native and natural to Rust. I come from a c++/ python background....
0
votes
0answers
47 views

Rust procedural macro (proc_macro) to generate static and dynamic bindings to system functions

This is my first attempt at a Rust procedural macro, so there might be a few spots where it can be improved. Reviews and recommendations welcome. The proc_macro: ...
3
votes
3answers
76 views

Join and map command line arguments in Rust

Is there a more natural way to do this in rust? I'm having a lot of difficulty trying to make this look clean. Type mismatches and borrowing have me stumped. What are some refactors that I could make? ...
1
vote
0answers
68 views

Quadtree implementation in Rust

To teach myself Rust, I implemented a simple Quadtree over 2D points with insert, delete, ...
2
votes
0answers
55 views

Minimal Static Site generator

For my first project with Rust, I decided to try and implement a minimal static site generator. I've never had any code review, and I've been looking for some feedback so I can get better! Brief ...
4
votes
1answer
60 views

Wavefront 3D Obj parser/viewer

For learning Rust I decided to make a 3D .obj viewer. I wrote a simplified OBJ parser without materials that only supports triangles. Considering I'm completely new to Rust and don't really know ...
4
votes
1answer
57 views

Simple income/expenses accounting program

I've decided to start working on a budget application for the purposes of getting started on Rust. In its current form this program takes given expenses and income and tells the user whether they have ...
-1
votes
1answer
57 views

Trying to convert struct with hashmap member

Consider a struct: struct RawData{ pub a: HashMap<String, String>, pub b: HashMap<String, String>, } which should be converted in a struct with ...
3
votes
1answer
55 views

Bin Numbers from stdin

I often like to get a feel for a text file containing a lot of numbers quickly by making a histogram. One can do this in plotting software like Gnuplot, but sometimes having something in the terminal ...
2
votes
1answer
127 views

Exposing a simple struct using Rust FFI

I am trying to expose a simple struct via FFI. Is this the best way to do it? I am not 100% sure about the get_text function. This is taking the string out of the struct and cloning it before ...
5
votes
2answers
107 views

Compute Manhattan distance from origin given a set of left-right-step directions

I am solving the problems for Advent of Code 2016 to learn Rust programming. The prompt for the first problem can be summarized: I start at position 0,0 on a regular grid. I am given a set of ...
5
votes
1answer
76 views

Game of Life in Rust-lang

I decided to implement Conways Game of Life for my first project using Rust. I also haven't had much code review ever, and have been looking for a good critique of my code so I can improve my skills. ...
3
votes
1answer
75 views

An asynchronous logger

I've written a simple asynchronous logger (playground): ...
4
votes
1answer
49 views

Using best practice with complex iteration

I'm new to Rust so I'm still learning how to use best practice in complex examples. Below is some code I've used in one of my programs, a simple implementation of a standard neural network. Here is ...
2
votes
2answers
121 views

Miller-Rabin Large Prime Generator in Rust

I implemented the Miller-Rabin prime test in Rust and made a program to generate large primes. I have also implemented the same program in C and Haskell and the Rust version is the slowest. I am ...
0
votes
0answers
20 views

Getting redis sentinel info in Rust

I've cobbled together some Rust code to display Redis master/slave information. As a Rust newbie, I'd appreciate some review feedback. ...
3
votes
0answers
65 views

Console Snake Game

I am beginning to learn rust and I created this snake game for practice. I am looking for some feedback on my code. main.rs ...
3
votes
0answers
35 views

Rust Iterator that correlates a slice with itself

In my effort to learn Rust I've tried implementing an Iterator that splits up a buffer in two halves, and correlates both halves by sliding them over each other with different positions (lags). You ...
3
votes
0answers
60 views

SHA256 implemented in Rust

I just finished making an implementation of a SHA256 hashing function (https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf) in Rust and I was looking for some feedback. As far as I can tell it ...
2
votes
0answers
36 views

Rust HTTP Requester

I am writing an HTTP client for terminal, similar to curl, as a learning exercise. There's one limitation it suffers from and that is that it won't return until the client closes the socket. I fixed ...
3
votes
1answer
49 views

Pidfile single process instance mechanism

I'm writing a system daemon in Rust that may be started by the user manually. Only one instance of the daemon should be running at a time so I have created a pidfile locking mechanism to prevent ...
4
votes
1answer
87 views

Linked List In Rust

I am still learning Rust and I think I have a long way to go. This question is from exercism.io. I am posting here to get some more reviews and suggestions to improve my code. Linked list aren't a ...
4
votes
0answers
233 views

Wait free triple buffer primitive

I'm trying to write a triple buffer that's wait free for a update + render loop after being bitten by lock starvation one too many times (on a different project, using a library). For reference, a ...
6
votes
1answer
90 views

Simple function to create Tokens from user input

I am new to programming in Rust and as an exercise I was making a simple Lottery checker program. It has a simple menu, the user enters a number for the corresponding option such as 'Add a line', '...
2
votes
0answers
24 views

Modelling a program with modules, symbols, and dependencies

My scenario is the following: I'm modelling a Program which has many Modules. Each Module has Symbols, some of which pointing at dependencies, which are other Modules. So a Module can be pointed to by ...