From b5ce2a9d36cd6567953558bb3b38560133f711f2 Mon Sep 17 00:00:00 2001 From: Rahul Baghel <106217726+rahulbaghel007@users.noreply.github.com> Date: Mon, 19 Feb 2024 11:34:22 +0530 Subject: [PATCH] Update 102-memory-safety.md Add missing content of Zero Cost Abstraction in Rust --- .../rust/content/100-introduction/102-memory-safety.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/data/roadmaps/rust/content/100-introduction/102-memory-safety.md b/src/data/roadmaps/rust/content/100-introduction/102-memory-safety.md index 314e3fd30..dde9df92c 100644 --- a/src/data/roadmaps/rust/content/100-introduction/102-memory-safety.md +++ b/src/data/roadmaps/rust/content/100-introduction/102-memory-safety.md @@ -1,3 +1,7 @@ # Memory Safety and Zero-Cost Abstractions -Rust, a systems programming language that runs blazingly fast, prevents segfaults, and guarantees thread safety. It is graced with the feature of "memory safety without garbage collection", an attribute that makes Rust one of its kind. Memory safety is ensuring that software, while accessing the system's memory, is not causing any leaks, or dangling pointers. In Rust, memory safety is accomplished through a system of ownership with a set of rules that the compiler checks at compile time. This system eliminates the need of garbage collection or manual memory management, hence ensuring swift execution of software along with a safer memory environment. This memory management feature in Rust even provides concurrent programming guaranteeing thread safety with options for shared and mutable state access that makes it harder to cause thread unsafety. \ No newline at end of file +Rust, a systems programming language that runs blazingly fast, prevents segfaults, and guarantees thread safety. It is graced with the feature of "memory safety without garbage collection", an attribute that makes Rust one of its kind. Memory safety is ensuring that software, while accessing the system's memory, is not causing any leaks, or dangling pointers. In Rust, memory safety is accomplished through a system of ownership with a set of rules that the compiler checks at compile time. This system eliminates the need of garbage collection or manual memory management, hence ensuring swift execution of software along with a safer memory environment. This memory management feature in Rust even provides concurrent programming guaranteeing thread safety with options for shared and mutable state access that makes it harder to cause thread unsafety. + + + +Zero cost abstraction is another key feature of Rust. In general, abstractions in programming languages allow code to be written at a high level (like in Python), while being able to run at a low level (like in C). However, these abstractions often come with a runtime cost. Rust aims to provide abstractions that are as fast as writing the code manually at a low level. This means you can write high-level code, and the Rust compiler will optimize it to run as fast as manually written low-level code.