A small Rust library simulation used for learning Rust and practicing basic ownership/borrowing and simple program structure.
This project contains a minimal command-line simulation of a library with:
Bookstructs (title, author, pages, available)Patronstructs (name, id)Librarywith methods to add/display/checkout/return books and query availability- Simple daily action simulation (checkout / return / browse)
Requirements
- Rust and Cargo (stable toolchain)
Build and run
cd library_sim
cargo build
cargo runThe program prints the library catalog, simulates several days of user actions (checkouts, returns, browsing), and prints availability statistics.
Cargo.toml— Cargo manifestsrc/main.rs— main program and core logic
- Add books using
Library::add_book()or by editingsrc/main.rssample data. - Run
cargo runto execute the simulation. Output includes daily actions and final availability counts.
Small fixes and improvements welcome. Suggested tasks:
- Add tests for
Librarymethods - Improve random action weighting
- Add CLI options for number of days, seed, or input file
This repository is provided for learning. Add a license file if you plan to publish (for example, LICENSE with MIT or Apache-2.0).