This repository contains a Rust script designed to help students understand the basics of Rust practically. The script demonstrates various advanced Rust features, including ownership, borrowing, lifetimes, traits, generics, and concurrency.
-
Traits and Implementations:
Summarizabletrait with a methodsummary.BookandArticlestructs implementing theSummarizabletrait.
-
Generics:
print_summaryis a generic function that works with any type implementingSummarizable.
-
Ownership and Borrowing:
- Demonstrated in the
ownership_and_borrowingfunction. - Shows how ownership is moved and how borrowing works.
- Demonstrated in the
-
Concurrency:
- Demonstrated in the
concurrency_examplefunction. - Uses
Arc(Atomic Reference Counting) andMutexfor thread-safe shared state. - Spawns multiple threads to modify a shared
HashMap.
- Demonstrated in the
-
Clone the repository:
git clone https://github.com/yourusername/Practical.git cd Practical -
Build and run the project:
cargo run
libc = "0.2.112"
This project is licensed under the MIT License.
Keagan Gilmore
keagangilmore@gmail.com