Rust Interview Questions
- syntactically similar to C++, but can guarantee memory safety.
- achieves memory safety without garbage collection.
- move semantics
- minimal runtime
- trait-based generics
- zero cost abstractions
- pattern matching
- type inference.
What are Modules in Rust?
- Importing Modules with
- Re-exporting with
What are "Cargo" and "Crate" in Rust?
- Cargo: a build system and package manager.
- Crate: a library or package.
Each crate has an implicit root module that contains the code for that crate. You can then define a tree of sub-modules under that root module. Modules allow you to partition your code within the crate itself.
Methods vs Associated Functions
You can have two kinds of procedures: methods and associated functions.
- methods: exists inside the struct implementation and receives the
&selfparameter, indicating that it needs to be called by an instance with a
- associated functions: called without an instance, it can be compared with the Java static functions. They are normally are used as a constructor of instances.
Name some Rust projects?
- https://github.com/bevyengine/bevy: A refreshingly simple data-driven game engine built in Rust.
- https://github.com/uutils/coreutils: coreutils written in Rust.
Trending Rust projects on GitHub: https://github.com/trending/rust
When to use
&self: when read-only reference is rquired.
self: when a value is to be consumed by the function.
&mut: when a value needs to be mutated by the function.