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
0answers
28 views

almostIncreasingSequence

This is assignment from codesignal: Given a sequence of integers as an array, determine whether it is possible to obtain a strictly increasing sequence by removing no more than one element from the ...
3
votes
0answers
25 views

Rust List comprehension macro

I'm very new to Rust and as I've been going through the book I became very interested in its macros. To better understand them I tried to write something of a usable list comprehension like those in ...
4
votes
0answers
30 views

Rust Iterative and Recursive Merge Sort Implementation

I'm in the process of learning both Rust and algorithms after primarily focusing on web development. As such I've had a go at implementing merge sort both iteratively and recursively. I've looked for ...
2
votes
1answer
39 views

Rust dynamic programming : word break

I've solved this problem: https://leetcode.com/problems/word-break Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, determine if s can be segmented into ...
4
votes
1answer
53 views

Rust Spelling corrector

It's been about a day since I've started writing some Rust, and I'm looking for some code review on a simple spell checker I've written up ...
4
votes
1answer
88 views

12 Days of Christmas in Rust

I've recently been trying to learn more rust and I have just finished chapter 3 of the Rust book, which has a list of projects to do to practice. I have tried to write a program that prints the 12 ...
1
vote
0answers
13 views

UDP to HTTP/2 DNS proxy

I've written my first ever Rust application, I'm looking for advice and criticism. It is a very small application, using Tokio async, and is meant to be single threaded. Mostly I'd like to know if I ...
8
votes
1answer
51 views

Boggle solver in Rust - Looking for speedup

I recently made a boggle solver in Rust to compensate for the fact that I'm really bad at boggle. This has also been a good Rust learning experience. The code does what it's supposed to quite well but ...
1
vote
0answers
46 views

Printing random lines from a file and compiling it to WebAssembly for web view

I want to learn Wasm and Rust. This project can execute Wasm from GitHub Pages. The first attempts failed because of some policy error with the Wasm MIME type. When I tried Yew Framework then it ...
1
vote
0answers
46 views

String parsing algorithm in Rust

I have written a recursive parsing algorithm for strings with nested brackets (I needed it to solve a molecules to atoms task). I would love to see how I could make ...
2
votes
1answer
30 views

Creating a thumbnail of a PDF using Cairo, Poppler and Rust

I want to create thumbnails from PDF files – specifically, a thumbnail of the first page. Currently I use pdftocairo on the command line: ...
10
votes
3answers
794 views

Writing slice compare in a more compact way

I have this code snippet comparing two slice references: ...
2
votes
1answer
147 views

Advent of Code 2019 Day 2 in Rust

I'm also doing the fun little Advent of Code challenges in order to learn Rust. Until now things went quite smoothly, but while I'm proceeding with the tasks I'd love to learn where I can actually ...
5
votes
2answers
109 views

Advent of Code 2019 Day 6 - Beginner Rust solution

I am doing Advent of Code 2019 in order to learn Rust (it's been fun, but challenging!). I am looking for help and feedback from more experiences Rustaceans on my solution to Day 6: Universal Orbit ...
2
votes
1answer
33 views

Shortening function calls with closures

I wrote this code that makes a fairly long function call multiple times using some of the same parameters ...
3
votes
0answers
68 views

Wrapping a C API to be implemented in rust

I'm writing a Rust library to facilitate implementing the following C API in Rust. That is, it should be possible to create a Rust-idiomatic implementation by depending on my wrapper library. ...
5
votes
1answer
82 views

Cache implementation in Rust

I've started learning Rust recently using the Rust book. In one of the chapters, the authors encourage the reader to experiment with closures, and try to create a generic cache implementation. I've ...
2
votes
1answer
49 views

Lex Scheme in Rust

I'm writing a Scheme interpreter in Rust, and the first step is the parser. I've finished the lexer, and would like to see what people think of it before I go any further. ...
4
votes
1answer
43 views

Summation Over Lines in a File (Advent of Code 2018 Day 1)

Preface: I am learning Rust through the Advent of Code The task is to read lines from a file, parse each as an integer, then provide a summation of all the numbers. My solution looks like this: <...
3
votes
0answers
72 views

Rust 2D grid class

This is the first time I‘ve used Rust, and I'd like to have some feedback on this project. The Grid class should be able to store objects of any type; it's a simple ...
2
votes
1answer
42 views

Reporting progress using a Follower

My goal is to implement a function that accepts a Follower object that will be used to report progress through a complex function (a depth-first traversal of a ...
5
votes
1answer
131 views

Shoe shine shop model in Rust and C++ - Follow-up

I've just refactored my Rust and C++ code which simulates the shoeshine shop model from this question. What else can be improved? C++: ...
5
votes
0answers
541 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 ...
17
votes
3answers
2k views

Shoe shine shop model in Rust

I'm learning Rust and a few questions did arise during translation of my C++ code to Rust. There are comments in Rust code I'd like to be answered. Is there an idiomatic way to solve this task? The ...
3
votes
1answer
58 views

Simple tree addition implementation

I am trying to learn Rust and I feel like a dummy every step of the way. I went through the tutorial on making lists in Rust. I am trying to apply the knowledge ...
0
votes
0answers
21 views

Random object identifier in Rust

For practical purposes as well as learning more Rust (this is my first attempt at publishing a crate) I created a random-id generator (named "objid" on crates.io). ...
0
votes
1answer
96 views

SHA256 hash bruteforcer

I made a SHA256 hash bruteforcer as my first program in Rust. It's very specific to what I'm trying to bruteforce and I'll probably never find it. I translated it from Python to make it faster, but ...
4
votes
1answer
98 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 (...
5
votes
1answer
100 views

Rust code that reads two columns of data from .txt file

I'm writing a code to read data from text file in Rust. The target files have two columns and non-fixed length rows, for example, example.txt 1 1 2 4 3 9 4 16 ...
3
votes
0answers
36 views

Molecular .pdb File Reader in Rust

I am new to rust and wanted to get going with a medium-sized project to help learn. I've settled on creating some basic quantum mechanics code which starts with this bare-bones file reader. It takes a ...
6
votes
2answers
88 views

Atbash Cipher in Rust - Exercism exercise

So I'm working on an implementation of the Atbash Cipher for Rust - it is an exercise on exercism.io. I come from a little C experience and found my code to be rather round about and kind of tortured. ...
3
votes
0answers
34 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
80 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
100 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 ...
5
votes
1answer
87 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
97 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
68 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
43 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
48 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
179 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 ...
5
votes
1answer
90 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
77 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 ...
5
votes
1answer
101 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
748 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
115 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
84 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
62 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
58 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
142 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 ...