https://github.com/iamteppei/rust-study
A rust study project
https://github.com/iamteppei/rust-study
Last synced: 10 days ago
JSON representation
A rust study project
- Host: GitHub
- URL: https://github.com/iamteppei/rust-study
- Owner: iamteppei
- Created: 2026-05-24T10:48:29.000Z (20 days ago)
- Default Branch: main
- Last Pushed: 2026-05-30T06:27:16.000Z (14 days ago)
- Last Synced: 2026-05-30T08:12:21.472Z (14 days ago)
- Language: Rust
- Size: 13.7 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Rust Study
A hands-on Rust learning project exploring core language concepts through annotated code examples.
## Topics Covered
### Ownership
Located in `src/ownership/study.rs`.
- **Stack vs Heap** — fixed-size data lives on the stack; dynamically sized data lives on the heap and is accessed via pointers.
- **Move vs Copy** — assigning a heap-allocated value (e.g. `String`) moves ownership; primitive types (e.g. `i32`) are copied.
- **Borrowing** — use `&variable` to pass a reference without transferring ownership (immutable by default).
- **Mutable references** — use `&mut variable` to allow mutation; only one mutable reference to a value is allowed at a time (prevents data races).
- **Reference rules** — you can have multiple immutable references OR one mutable reference, but not both simultaneously.
- **Dangling references** — Rust's compiler prevents returning references to values that have been dropped.
- **Slice type** — a reference to a contiguous sequence of elements in a collection; holds no ownership.
## Project Structure
```
src/
main.rs # Entry point
ownership/
study.rs # Ownership, borrowing, and slice concepts
```
## Local Setup
### Prerequisites
- [Rust & Cargo](https://rustup.rs/)
### Run
```bash
cargo run
```
### Watch mode (auto-rerun on file change)
Install `cargo-watch`:
```bash
cargo install cargo-watch
```
Start modules
```bash
# ownership
cargo watch -w src -x "test ownership"
# pattern matching
cargo watch -w src -x "test pattern_matching"
# functional programming
cargo watch -w src -x "test functional_programming -- --nocapture"
```