Rust - Concept of Data Freezing Last Updated : 08 Sep, 2022 Comments Improve Suggest changes Like Article Like Report Rust is a systems programming language. In Rust, there is a concept of freezing which states that whenever data is borrowed, the borrowed data is also frozen. This frozen data cannot be modified until the references get out of scope i.e. all the bindings go out of scope. Suppose in the given below example, we declare a mutable integer _mut_integer. Here, we are shadowing the immutable variable _mut_integer but we see that _mut_integer is already frozen in this scope as the data is bounded by the same name. After the curly braces, _mut_integer goes out of scope. Example 1: Rust fn main() { let mut _mut_integer = 8; // mutable integer { // Borrow `integer` let _reference_to_integer = _mut_integer; // integer is frozen in this scope _mut_integer = 7; println!("{}", _reference_to_integer); println! ("{}", _mut_integer) // `reference_to_integer // goes out of scope beyond here } _mut_integer = 4; // immutable integer println!("{}",_mut_integer); } Output: Â Comment More infoAdvertise with us Next Article Rust - Concept of Data Freezing S sayanc170 Follow Improve Article Tags : Rust Rust functions Similar Reads Rust - Concept of Ownership Rust programming language is known for its memory management. This article explains how Rust uses its Ownership model for better memory management. If you want to have a recap of Rust syntax before getting on this article you can refer to the Rust Archives. Generally, there are 2 ways to manage memo 4 min read Storage Concepts in System Design In system design, storage concepts play an important role in ensuring data reliability, accessibility, and scalability. From traditional disk-based systems to modern cloud storage solutions, understanding the fundamentals of storage architecture is crucial for designing efficient and resilient syste 9 min read Data Races in C++ In C++, data race is a commonly occurring problem in concurrent programming. It occurs when two or more threads concurrently access the same memory location, and at least one of the accesses is a write. Data races lead to undefined behaviour, which means the program can exhibit unpredictable behavio 5 min read Rust - Concept of Smart Pointers Pointers are basically variables that store the address of another variable. Â While smart pointers are data types that behave like a traditional pointer with additional capabilities such as automatic memory management or bounds checking. What makes smart pointers different from normal pointers are:- 4 min read File I/O in Rust File I/O in Rust enables us to read from and write to files on our computer. To write or read or write in a file, we need to import modules (like libraries in C++) that hold the necessary functions. This article focuses on discussing File I/O in Rust. Methods for File I/O Given below are some method 7 min read Like