3 days playing with Rust (and I love it!)

About this article

Why Rust?

Setup the environment

Cargo

Cargo.toml

OOP

Struct definition used to load each row in our csv file
how_old method used to know the years since a show was released
  • Each statement ends with semicolon. If the last statement in a function doesn’t end with semicolon, it will be interpreted like the return of the function. The both following examples are the same.
return keyword can be omitted
use return keyword
  • self keyword permits access to the object attributes and methods.
  • By default, the variables are inmutables. To make them mutables we need to use the keyword mut.
error: cannot borrow `items` as mutable, as it is not declared as mutable
Correct definition of variable items
Alias used to name a vector of shows
Parser trait to be implemented by csv parser
String variables could use this new function to_vector

Imports

We can define mods, structs or just functions

Custom errors

FileNotFound error definition
Throwing our own errors

Closures

Code organization

Macros

Functional programming

Sample of use in Rust

Source code

  • Documentation of crate serde (used to serialize the domain) can be found here https://serde.rs/

What can you do next?

  • Create a new executable file. (Modify Cargo.toml and create a new file in bin directory)
  • Print the title (in uppercase) of the shows whose release date is lees than 3 years.(and any other query that you want to try).
  • Code an implementation for loading the file netflix.json in resources directory. The command should be

Must read articles & tutorials

My feeling

--

--

--

If tech can change the world... why don't we use it to make it better? https://www.linkedin.com/in/ivan-corrales-solera/

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Frontend Mentor May 2021 review

338 Tips for the AWS Certified Sys Ops Admin Associate Exam

Web hosting in Google cloud , when to use what ?

Disable cache in Nginx

Weekly-mendations #031

A Long-Awaited Update: Where is the NFT Marketplace?

Next up — OSCP Lab Machines

Integrating HUAWEI In-App Purchases Using Unity

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Iván Corrales Solera

Iván Corrales Solera

If tech can change the world... why don't we use it to make it better? https://www.linkedin.com/in/ivan-corrales-solera/

More from Medium

Functional vs Object-oriented programming

Implementing a custom collection type in clojure — the leftist heap, a persistent priority queue

A teacup placed on a pile of books

Demystifying String Types in Rust

Compiler Adventures, part 2: Constant Propagation

A blurry photo of a galaxy, with a bright blob in the middle surrounded by fuzzy swirling clouds of gas. Next to it, a crisp and sharp image of the same galaxy, showing many dots of light and and individual clouds where previously there was just a blur of color.