Comments (10)
Hello :)
My solution is available here - it's really not perfect...
I can't wait to see your new video on the subject ;)
from show.
Hi @mre ! Thanks for this awesome challenge.
It uses std::str::FromStr
trait and the ?
(question mark) operator extensively (each parsing step returns a Result
). It also checks whether a given day is valid in a given month (eg. 31 of April is considered invalid, because April has 30 days), although it's very forgiving when it comes to the special case of February (max. 29 is always allowed).
from show.
I updated my code - added leap year validation in case of February 29th 😉 .
from show.
Here's my submission, I used it as an excuse to learn a bit about nom. The tests aren't the BEST organized, but the majority are there:
https://gist.github.com/LivingInSyn/4a0b88a3cce0c58e9331f937aa520ab9
from show.
Whelp, something like this could work, yeah.
let day: u32 = parts[0].rmatches(char::is_numeric).nth(0)?.parse()?;
Here's the code with some error handling:
https://play.rust-lang.org/?gist=487104fd94fedde58d75ba0f480e4d49&version=nightly&mode=debug
Whether you prefer that over the given solution is a matter personal taste I guess. 😉
from show.
Thanks for that @k0pernicus 😃
from show.
Thanks you two! ❤️
from show.
Hey, instead of listing all options, can we do something like this:
let day: u32 = parts[0].rmatches(char::is_numeric).collect()?;
If so, how would you add error handling?
I’m liking the episodes by the way. Keep up the good work!
from show.
Thanks for all the contribution. Show notes are here: https://github.com/hello-rust/show/tree/master/episode/7.
I really appreciate it and it makes the show better.
I might ask you to do more of that in the future and contribute to a future episode.
Might be more code samples, might be reviewing my code, might be an interview - who knows.
But I hope we can keep this going as I love to learn from your code and your feedback! ❤️
from show.
I'd be more than happy to help further, the 'assignment' was fun and an excuse to learn something new :)
from show.
Related Issues (20)
- Debugging tutorial
- Code coverage workshop
- Messing with emulators
- kafkacat HOT 3
- Compiler internals
- Hi there, can we have this show back? HOT 6
- Alphanumeric String Sort
- Port glibc's strstr to Rust
- Create an async htop
- Async port scanner
- Port showboost to Rust
- Tips for faster compile times
- Link checker like l liche HOT 1
- chars
- Build your own search engine
- Rust frontpage HOT 1
- Rust static analysis tools
- Vscode Setup HOT 5
- Recursive data structures HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from show.