Learning basic Rust concepts
While Rust is quite an extensive language and to cover it completely requires a book of its own, you are advised to supplement your learning with a dedicated Rust book. You can find some examples at https://doc.rust-lang.org/book/. However, the most important concepts that we will often require when working with blockchains can be covered quickly. This is what we will attempt to do here.
First, let’s talk about variables and constants. These are the basic building blocks of any programming language.
Variables and constants
Variables are crucial to Rust as they are values that may change multiple times throughout the lifetime of the program. As can be seen in the following example, defining variables in Rust is extremely simple:
fn main() { let x = 5; println!("The value of is:{x}"); }
In the preceding code, we assign a value of 5
to x
, where x
is the variable, after which we print out the...