From the course: Rust Essential Training
Unlock the full course today
Join today to access over 22,500 courses taught by industry experts or purchase this course individually.
Multidimensional arrays - Rust Tutorial
From the course: Rust Essential Training
Multidimensional arrays
- Arrays in Rust can have more than one dimension. If we think of a basic one-dimensional array as being like a row of parked cars with each spot having a unique index number to identify it, then a two-dimensional array is like a parking lot where you'll need two index values to locate your car. You'll need to know which row you parked on, and then which spot along that row. Taking that analogy even further, a three-dimensional array is like a multi-story parking garage. To find your car, you'll need three index values. Which floor you parked on, which row on that floor, and then which spot along that row. It's hard to imagine a four-dimensional parking garage. So we'll stop the analogy there. We can initialize a two-dimensional array in Rust by nesting several one dimensional arrays within another array. This initializes two arrays with three elements each. The first one contains one, two, three, and the second one…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Download courses and learn on the go
Watch courses on your mobile device without an internet connection. Download courses using your iOS or Android LinkedIn Learning app.
Contents
-
-
Declaring variables5m 46s
-
(Locked)
Integer data types6m 51s
-
(Locked)
Floating-point data types5m 34s
-
(Locked)
Arithmetic operations6m 37s
-
(Locked)
Formatting print statements5m 40s
-
Bitwise operations10m 46s
-
(Locked)
Boolean data type and operations5m 4s
-
(Locked)
Comparison operations3m 5s
-
Char data types2m 36s
-
(Locked)
Challenge: Find the average1m 20s
-
(Locked)
Solution: Find the average3m 20s
-
-
-
(Locked)
Conditional execution3m 38s
-
(Locked)
Multiple conditions3m 45s
-
(Locked)
Conditional assignment3m 41s
-
(Locked)
Loops3m 45s
-
(Locked)
While loops4m 55s
-
(Locked)
For loops6m 35s
-
(Locked)
Nested loops2m 51s
-
(Locked)
Challenge: Max, min, mean1m 13s
-
(Locked)
Solution: Max, min, mean2m 25s
-
(Locked)
-
-
(Locked)
Implement traits4m 33s
-
(Locked)
Default trait implementation1m 33s
-
(Locked)
Derive traits3m 58s
-
(Locked)
Trait bounds3m 8s
-
(Locked)
Multiple trait bounds5m 16s
-
(Locked)
Return types with implemented traits3m 40s
-
(Locked)
Challenge: Implement the display trait1m 16s
-
(Locked)
Solution: Implement the display trait1m 53s
-
(Locked)
-
-
(Locked)
Define enums3m 43s
-
(Locked)
Match operator2m 43s
-
(Locked)
Match with default placeholder4m 34s
-
(Locked)
Enum methods3m 4s
-
(Locked)
Option<T> enum5m 15s
-
(Locked)
Matching Option<T>1m 31s
-
(Locked)
If-let syntax1m 57s
-
(Locked)
Challenge: Represent a location1m 4s
-
(Locked)
Solution: Represent a location1m 20s
-
(Locked)