Data types - Rust for C-Programmers
Rust is a statically typed language, meaning the type of every variable must be known at compile time. The compiler can often infer the type, but you can also provide explicit type annotations. Once assigned, a variable’s type cannot change. Rust offers a standard set of primitive types: In addition to value types like i32, Rust also supports references—safe, managed pointers that refer to data stored elsewhere in memory. Similar to C pointers, references hold the address of a value, introducing a level of indirection. Rust references can be either immutable or mutable, allowing temporary access to data without transferring ownership or making a copy. This is especially useful for passing data to functions efficiently. To create a reference, Rust uses the & operator for immutable access and &mut for mutable access. The * operator can be used to access (dereference) the value behind a reference, although in many cases this happens implicitly. References are covered in more depth in Chap
Explore this link on the map →