Basic Types for Rusts
Basic types in Rust are the structs, enums and collections used to model data. Structs group named fields, enums express a value that is one of several variants, and Option and Result are enums from the standard library. Vec, String and HashMap are the main growable collections.
Stage: Ownership · Part of the Rust roadmap · Last reviewed 19 November 2026
What to learn in Basic Types
- Define a struct and add methods in an impl block
- Model alternatives with an enum whose variants carry data
- Use Option instead of null values
- Store and iterate items in a Vec and a HashMap
- Choose between String and &str in function parameters
Basic Types interview questions
Why does Rust have Option instead of null?
Option<T> is an enum with Some(value) and None. The type system forces you to handle the missing case before using the value, so null pointer errors cannot occur by accident. Methods like map, unwrap_or and the ? operator make handling concise.
What is the difference between String and &str?
String is an owned, growable, heap-allocated text buffer. &str is a borrowed view into string data, such as a literal or part of a String. Functions usually accept &str for flexibility and return String when they create new text.
Where Basic Types fits in the Rust roadmap
Basic Types belongs to the Ownership stage (intermediate level), which takes about 28 hours. The core idea.