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
0answers
23 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? ...
3
votes
0answers
44 views

HTTP download function in Rust (async/await)

Why am I fighting the compiler? - Wrote this, which works, but I feel like I'm breaking every rule in the book: ...
6
votes
1answer
218 views

Brainfuck interpreter utilizing idiomatic Rust

I'm learning Rust at the moment, I've read the book and been just playing around with the language. I wrote this simple Brainfuck interpreter, because I think that it's always a fun exercise. The ...
5
votes
0answers
75 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 ...
1
vote
0answers
39 views

Implement a micro service in Rust

Last year I tried to implement a micro service architecture in Rust. The imageined use case was a small izakaya-shop where digital orders could be given to the kichen tracked or deleted. Looking for ...
2
votes
2answers
76 views

Encrypt data before sending it to server in a way that makes it unreadable to anyone except the user who sent it

I don't have any experience in cryptography and I've written some crypto code that seem to be working, but I'm not sure if it safe and if the tools and methods I used are right. Objective Make it ...
4
votes
1answer
58 views

Lexer written in Rust

So I ported a lexer I wrote in C++ over to rust, as I'm starting to learn rust. Since I'm very new though, I don't know any Idioms and good practices in rust. So if anyone could point out some (...
1
vote
0answers
26 views

color and canvas implementations in Rust for Ray Tracer Challenge

I'm learning Rust by working through Jamis Buck's The Ray Tracer Challenge. The book instructs the reader on what to build in what order, and provides all required test cases. Included here are my ...
3
votes
1answer
49 views

Find a file in current or parent directories

As a Rust beginner, I would like to know how I could improve the following points considering the function below: Handling Path and ...
11
votes
4answers
878 views

Writing slice compare in a more compact way

I have this code snippet comparing two slice references: ...
15
votes
1answer
6k views

Calculate mean, median, and mode in Rust

I'm learning Rust using The Rust Programming Language. I'm trying the assignment at the end of chapter 8 — Hash Maps. The task is: Given a list of integers, use a vector and return the mean (...
2
votes
0answers
66 views

Rust/WebAssembly VS pure JavaScript benchmark in Node.js

I've wanted to try Rust and WebAssembly for a while. I recently realized that I could try both at the same time by compiling Rust to WebAssembly. I wanted to know what the performances of something ...
2
votes
0answers
40 views

recursive-file-watcher in rust

hello guys i made a file watcher in rust using notify crate that watches a directory and if it detects file changes it will copy all of the files within the directory to another directory,i wanted you ...
1
vote
1answer
37 views

Target src/main.rs::main()? [closed]

I'm basically wondering what the optimal method for returning to the top of src/main.rs::main() is? Maybe something like this: ...
2
votes
1answer
42 views

Rust Hamming Code Quizzer

I am currently learning Rust. To allow myself to practice, I created the following program that helps the user to practice hamming codes (the goal is for the user to use this program to be able to ...
1
vote
1answer
67 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)...
5
votes
2answers
122 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 ...
0
votes
1answer
79 views

Factorial number in Rust for learning purposes

I'm currently trying to learn the basics of the Rust programming language, to do this my first piece of code after the classic 'Hello World' was a simple recursive Factorial function. This is the ...
4
votes
1answer
112 views

Rust Iterator Fizzbuzz

Rust is one of my first forays on a strongly typed language, beginning to like it's strictness, and am looking to improve my comprehension. Rules Fizzbuzz is a programming challenge with the ...
5
votes
0answers
52 views

Brainf*** interpreter in Rust

I'm learning Rust coming from an intermediate background in Python. I've completed the first 8 chapters of the book and I wanted a project that would solidify the concepts I learned, so I made a ...
4
votes
0answers
62 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 ...
3
votes
0answers
34 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 ...
2
votes
1answer
57 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 ...
1
vote
0answers
58 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 ...
2
votes
1answer
46 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: ...
4
votes
1answer
58 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
100 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
20 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 ...
3
votes
1answer
908 views

BTreeMap as a multimap in Rust

I'm learning Rust so as an exercise I'm trying to write a datatype wrapping the builtin BTreeMap to allow it to store duplicates. Like the STL multimap type. The ...
8
votes
1answer
58 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
53 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 ...
4
votes
1answer
71 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 ...
5
votes
2answers
115 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 ...
3
votes
0answers
73 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. ...
4
votes
1answer
44 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: <...
2
votes
1answer
153 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 ...
2
votes
1answer
35 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 ...
5
votes
1answer
136 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++: ...
2
votes
1answer
57 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. ...
5
votes
1answer
95 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 ...
4
votes
1answer
103 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 (...
3
votes
0answers
76 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
43 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
0answers
544 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
64 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
22 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
99 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 ...
3
votes
1answer
117 views

Simple Brainfuck Interpreter in Rust

Not a long time ago, I got into Rust and I made a simple Brainfuck Interpreter. Now I want to get back to Rust and I would like some comments on my code: Just in case it's hard to read code from post:...
4
votes
0answers
37 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 ...

1 2 3 4 5 9