All Questions
26 questions
7
votes
1
answer
357
views
piglatin exercise in rust
This is my attempt to make the exercise suggested at the end of this chapter of rust's official tutorial
...
0
votes
1
answer
55
views
Protein Translation Learning Exercise from exercism.org
I'm learning Rust by solving exercises from different tracks on Exercism.
The below code is an implementation of "Protein Translation" from the Python track. I split ...
1
vote
1
answer
39
views
Rust program to print citations in Chicago author-date style
I have written a Rust program that lets you input a citation's metadata in a Bibtex-like format and generates a bibliography entry formatted in Markdown that conforms (more or less) to the Chicago ...
2
votes
1
answer
94
views
The Rust Programming Language Pig Latin
This is my implementation of the Pig Latin recommended exercise in The Rust Programming Language book. Any pointers on making this code more idiomatic or run more optimal?
...
1
vote
1
answer
153
views
Rust - insert into piecetable
I'm writing a piece table library in Rust with the structures:
#[derive(Default)]
struct Piece {
additional: bool,
offset: usize,
length: usize,
}
and
<...
3
votes
1
answer
3k
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
1
answer
366
views
Rust echo implementation that supports command line options
I rewrote echo from the manpage to learn Rust, and got the following:
...
5
votes
1
answer
296
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 ...
3
votes
1
answer
2k
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:
...
2
votes
0
answers
42
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 ...
4
votes
0
answers
166
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 ...
4
votes
0
answers
60
views
Translating Python to Rust: reading a Salesforce ID from a string
As a first project in Rust, I'm translating an existing, working piece of Python code. This code's purpose is to convert a 15-character Salesforce Id (which is guaranteed to be ASCII, exactly 15 bytes ...
3
votes
1
answer
59
views
Find a valid english phrase that is identical to what the user entered, save a missing consonant
The Task:
The user enters a path to a dictionary file (one word per line) and a phrase as system arguments. My code must then find phrases containing only valid English words, generated by removing ...
7
votes
1
answer
2k
views
Find the longest common sequence of two strings in Rust
I've attempted to solve a small coding challenge I found online as a nice way to begin learning Rust. The largest challenge I feel going in with Rust is how working with strings is so fundamentally ...
1
vote
1
answer
331
views
Convert a type u16 number to a matrix (Vec<Vec<u8>> or array) of 4 x 4
I am a Rust newbie and I am not familiar with all the iterator options. This is what I have so far. How can I make this better or at least avoid collecting twice into a Vec?
...
8
votes
2
answers
817
views
Rust Echo Command Implementation
I'm just starting out in Rust and I find the concept of ownership confusing so I wrote an implementation of the echo command. I would like to know if I could have ...
5
votes
1
answer
4k
views
Convert string of hex into vector of bytes
I want to write a function that gets a string of hex numbers (two hex numbers represent a u8 value) then returns a vector of u8 ...
2
votes
1
answer
163
views
Pig Latin translator with too many `push_str`s
I'm learning Rust and one of the challenges in the book was to build a pig latin translator.
Convert strings to pig latin. The first consonant of each word is moved to the end of the word and “ay” ...
8
votes
1
answer
1k
views
Replace string in file
This is my first module I wrote in Rust. I'm new to the language and couldn't find a way to easily replace some words in a file, so that's my go at it. If there's already something like that and I ...
4
votes
1
answer
189
views
Peter Norvigs spellcheck in Rust
For a Rust project I'm working on I needed a (simple) spellcheck algorithm and I set out to re-implement Peter Norvigs spellcheck algorithm in Rust.
...
6
votes
1
answer
3k
views
Transposing characters in a string
I want to create a function that takes a string and returns an array of versions of it in which always one pair of characters is transposed (swapped).
I came up with this:
...
3
votes
1
answer
90
views
Read file contents to string safely
I've just started to teach myself Rust. I've written the following code to read a text file and store the contents in a String. Is this the typical way of doing ...
6
votes
2
answers
284
views
X-up utility for EVE Online
I am learning Rust.
I also play EVE Online – a video game about internet spaceships. I decided that it would be fun to practice Rust by writing a simple utility to help me x up.
to x up (verb)
...
6
votes
2
answers
2k
views
Jaccard distance between strings in Rust
The Jaccard distance between two sets is the size of their intersection divided by the size of their union. For example, the distance between {1, 2, 3} and ...
2
votes
2
answers
207
views
Rosalind string algorithm problems
I've been starting to learn Rust by going through some of the Rosalind String Algorithm problems.
If anyone would like to point out possible improvements, or anything else, that would be great. There ...
11
votes
2
answers
7k
views