- Create a CRUD application to be familiar with Rust.
- Use various features even it's not necessary, just for an educational purpose.
- CRUD of a simple entity: User
- CRUD of a simple entity: Post
- 08/19/2023: Connect to database(mysql), add GET user api
- 08/20/2023: Fix compile errors in 1, Add POST, DELETE, PUT user api
- 08/26/2023: CRUD of Post entity
- 09/02/2023: Exception handling + middlewares - best practices
- 09/17/2023: Dockerization
- 09/23/2023: Refactoring - divide into modules
- Exception handling
- ADD middlewares
- Refactoring - divide dependencies into modules
- Unit Tests
- Use multithreading + async/await even it's not necessary
- Add hot reload
- Add auth
- Db connection pooling - already did it
- Add Dockerization
Closure - function-like construct that can capture its surrounding environment.
Closures are similar to lambdas or anonymous functions in other programming languages.
Closures in Rust have a unique feature: they can capture their environment in three ways: by reference, by mutable reference, or by value
You can use move
keyword before the parameter list to force the closure to take ownership of the values it uses in the environment.
Especially in concurrency programming, you can use move
keyword to transfer ownership of the values to the closure so that the closure can be executed in another thread.
use std::thread;
let message = "Hello from a thread!".to_string();
thread::spawn(move || {
println!("{}", message);
}).join().unwrap();