Commonly used Rust Data Structures and Concepts from the Standard Library

Notes preparing for the coding interview using rust 

(data structures and concepts commonly seen from rust standard library)

Vectors (Vec): Vectors are dynamic arrays that can grow or shrink in size as needed. They are commonly used to store collections of values.

Hash maps (HashMap): Hash maps are associative arrays that map keys to values. They are commonly used to store key-value pairs and to implement caches and dictionaries.

Strings (String and str): Strings are sequences of characters. They are commonly used to represent text data.

Iterators (Iterator): Iterators are objects that produce a sequence of values, one at a time. They are commonly used to iterate over collections of values and to perform operations such as filtering, mapping, and reducing.

Collections: In rust, a collection is a data structure that contains multiple values. Some common collection types in Rust include Vec, HashMap, HashSet, BTreeMap, and BTreeSet. These types are part of the standard library and provide a wide range of functionality for storing, organizing, and manipulating collectons of values.

Collections are widely used in coding interviews to solve problems that involve grouping, counting, sorting, or searching for values. Understanding how to use collections effectively is an important skill for solving coding interview challenges in Rust.

Tuples ((T1, T2, ..., Tn)): Tuples are fixed-size collections of values of different types. They are commonly used to group related values together.

Result (Result): The Result type represents the result of a computation that may succeed or fail with an error. It is commonly used for error handling.

Option (Option): The Option type represents an optional value that may or may not be present. It is commonly used to handle nullable values and to represent the result of computations that may fail.

Slices ([T]): Slices are dynamically-sized views into contiguous sequences of values. They are commonly used to represent arrays or parts of arrays.

5. Slices ([T]):

6. Tuples ((T1, T2, ..., Tn)): Tuples do not have any inherent methods. Instead, you can use pattern matching to extract their elements or access them directly using dot notation (e.g., tuple.0, tuple.1, etc.).

7. Option (Option):

8. Result (Result): -.is_ok():Returns true if result is Ok variant -.is_err():Returns true if result is Err variant Result<T,E> to Result<U,E> by applying function to contained Ok value leaving Err value untouched -.map_err():Maps Result<T,E> to Result<T,F> by applying function to contained Err value leaving Ok value untouched -.unwrap_or():Unwraps result yielding content of Ok or default value

9. Collections: Collections are data structures that contain multiple values. Some common collection types include Vec, HashMap, HashSet, BTreeMap and BTreeSet. Each collection type has its own set of methods for adding, removing, and accessing elements. Some common methods include .len(), .is_empty(), .insert(), .remove(), and .get().