Rust Internals: Memory Usage and Efficiency
How Type Alignment,Layout and trait objects affect Rusts Memory Usage and Efficiency As software engineers, we are always striving to write efficient,performant and cost effective applications. I...
How Type Alignment,Layout and trait objects affect Rusts Memory Usage and Efficiency As software engineers, we are always striving to write efficient,performant and cost effective applications. I...
Methods Syntax They are defined within the context of a struct/enum/trait object, with the fn keyword, can have arguments and return values. Their first parameter is self and represents an instan...
References and Borrowing A reference is an address we can follow to access data owned by some other value. Unlike a pointer, a reference is guaranteed to point to a valid value of a particular ty...
Ownership A set of rules that govern how Rust manages memory.If any of these rules are violated, the program won’t compile. Rust doesn’t have a garbage collector like other languages therefore it...
Structs Custom datatype that packages related data. A struct’s name should describe the significance of the pieces of data being grouped together There are 3 types: Normal Structs Tuple Str...
Functions Use the fn keyword to declare new functions followed by function name which has to be of snake_case conventional standard and a set of parentheses. The below function represents the mai...
Data types Rust is a statically typed language. Therefore, it must know the types of each value at compile time. Every value is of a certain data type, which tells rust exactly how to interact wit...
Variables By default, variables are immutable. Rust encourages you to favour immutability inorder to take advantage of it’s safety and easy concurrency features, but sometimes you might want to op...
VSCODE Download and install vscode here. Once installed, install the rust-analyzer extension for code completion with imports insertion go to definition, implementation, type definition f...
Installing Rust Windows Download and run rustup-init.exe Linux or macOS Run curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh in your shell. This downloads and runs rustup-init.sh,...