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

Sphax PureBDcraft Hero Skin

Automate IT Production Support using RPA & AI

Symprio Oracle Support Automation using RPA

Building the clone of Groww website

Use Kotlin as a refactor tool

.Net Core 3.0 API Best Practices

Saving Time with Python and Tableau

Google Colab-Getting Started

Azure DevOps — Agent Pool

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

Getting started with the PicoLisp database

Elixir — A Tincture for Functional Programming Part 1.5 Recursion

Ouroboros

Testing in Rust

Performance Optimisation — Advanced FP part 3