Useful Rust features
Still need to make the compiler happy
Leaving off from last time
- Exercises:
- Rustlings exercises for move semantics
- Parsing file into string slices
- Anything regarding the borrow checker or Rust?
Exercises for today
- Enums
- Vecs
- Iterators
- Error handling
More exercises (in-class and HW)
- Web backend API for a basic in-memory key-value store:
- PUT /<key>
Saves the request payload (body) as the value
- GET /<key>
Responds with the saved payload, or responds with 404 if there's nothing saved with that key
- DELETE /<key>
Deletes the key
- Use actix-web or another async webserver library
- CSV to JSON converter
- Given a CSV with header rows specified, output corresponding JSON to standard out with field names
- Might want to use "serde_json" crate or "simdjson" crate
- Example:
input.csv
first_name,last_name,age,hometown
johnny,johnson,29,mexico
jason,apple,21,usa
amy,barker,38,europe
allen,harper,93,england
jeremy,staller,19,australia
Run: csv2json input.csv
Outputs:
[
{
"first_name": "johnny",
"last_name": "johnson",
"age": "29",
"hometown": "mexico"
},
...
]