In Rust, we can read user inputs from the command-line console. These inputs are string values with newline characters at the end. Most of the time, we do not want those extra characters. This post provides three simple example codes
Using #[non_exhaustive] for Non-exhaustive Enums
Using non-exhaustive enums in one crate prevents codes in other crates from listing all the possible matches in a match expression. It forces developers to use wildcards for future-proofing.
How to use Local Unpublished Crates
At some point in learning Rust, we will encounter the need to create our own crates. They need to go through development and testing before there are published to creates.io. This brief post is about creating and using local unpublished crates.
Pattern Matching for Declarative Macros in Rust
Macros are like functions but only better. They are triggered based on their patterns using pattern matching for declarative Macros. They group together our codes into a unit (or units) and there are 2 types of macros in Rust – declarative and procedural. This brief post is about declarative macros.
Have You Started Using Actix-Web? It May Already Be Dead
Have you started using Actix-Web in your learning of Rust or real projects? Actix-web is now dead and no longer an open-source project. The author has moved it, along with Actix-Net, to his personal GitHub account. He is taking his
Rust Core Data Types To Get Familiar With
Rust has two types of core data types – scalar and compound. Scalar types are single-value types, while compound types are multi-value types. Integer Data Types An integer data type is one of Rust’s core data types that represents a
Custom Data Types With Struct, Trait, And Enum In Rust
We can create custom data types in Rust using struct, trait, and enum. A struct is a composite data type that groups variables in a memory block. These variables are then accessible via the struct’s instance – also referred to
Enum Variants And Match Expressions In Rust
There are a few ways to define an enum variant and, as a result, to use it when creating match expressions. We can define a variant in three ways – one-word, Tuple-like, or Struct-like. Match One-Word Enum Variants Let’s say
Rust And Ubuntu 18.04 Docker Image
This post shows how to build a Ubuntu 18.04 Docker image with installed Rust. We can use the image to build Rust applications, but the codes are in the host Windows system. When we compile the codes, we need to
How To Modify Struct Instance In A Function in Rust
This post shows how to modify a struct instance in a function. It uses the mutable shared borrowing to pass a mutable reference as an argument to a function. Struct And Instance Consider the following Person struct. It has two