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
The Into and Unwrap Methods In Rust
Developers new to Rust probably have encountered the into and unwrap method calls several times in sample codes. At first sight, these calls may appear puzzling to them. So, where do we use these methods? Chances are these methods that
Actix-Web In Ubuntu Docker Container Not Accessible
An Actix-Web application in an Ubuntu Docker container may not be accessible from the host operating system. For non-production codes and configuration, it may be due to two factors. Actix-Web Is Not Accessible in Docker Container Due to Rust Codes
Deploy Actix-Web In Docker Container
We can deploy a Rust application based on the Actix-Web framework in a Docker container when we are coding in Windows. In this post, we compile Rust codes on Windows but deploy the application to an Ubuntu 18.04 Docker image.
Ways to Create Temporary Files In Rust
Creating temporary files in Rust is sometimes essential when we need to use the files once or cache data for a short time. We then let the operating system delete the files at a later time automatically or by its
Swap Between Vec Elements in Rust
Swapping between Vec elements in Rust can be a little tricky. The get method returns Option<&T>, and the lone swap method accepts an index and a value – not a reference. There is an alternative, though. But it uses unsafe codes.
Show Rust Dependencies Using Cargo
It is now possible to show Rust dependencies using Cargo. Before Rust 1.44.0, there was not a built-in method to display a dependency graph. There was a plugin, though, called cargo-tree. Show Rust Dependencies Using Cargo-tree With the cargo-tree plugin,