Rust (language) Flashcards
What is Rust primarily known for in terms of programming language design?
Rust is known for safety, performance, and concurrency.
Which system does Rust use to manage memory safely without a garbage collector?
Rust uses an ownership system.
How does Rust prevent common bugs like dangling pointers and double frees?
Rust enforces memory safety at compile time using ownership rules.
What are the two types of borrowing in Rust?
Immutable borrowing and mutable borrowing.
Fill in the blank: Rust allows either _______ or _______ borrowing, but not both at the same time.
immutable, mutable
What is a key advantage of Rust’s memory model compared to garbage-collected languages?
Rust provides memory safety without a garbage collector, improving performance.
How does Rust ensure memory is deallocated safely?
Memory is deallocated automatically when data goes out of scope, using Rust’s ownership system.
What does Rust’s concept of ‘lifetimes’ prevent?
Lifetimes prevent references to data that has already been deallocated.
What are zero-cost abstractions in Rust?
Abstractions that have no runtime cost, allowing high-level constructs without performance penalties.
Why is Rust’s performance comparable to C or C++?
Rust compiles directly to machine code, without an interpreter or virtual machine.
How does Rust handle concurrent access to data safely?
Rust uses ownership and borrowing rules to prevent data races at compile time.
How does Rust enable safe concurrency?
Rust enforces strict rules on data access and modification across threads.
What feature does Rust include to facilitate multithreading and safe communication between threads?
Channels for message-passing concurrency and built-in multithreading support.
Fill in the blank: Rust’s ______ and _______ allow threads to communicate safely without sharing memory directly.
channels, threads
What is Cargo in Rust?
Cargo is Rust’s package manager and build system.