Simplify todos_index in todos example (#3048)

This commit is contained in:
Jonas Platte 2024-11-26 18:56:29 +01:00 committed by GitHub
parent 69a89c00e7
commit f1c79a459b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -82,14 +82,9 @@ pub struct Pagination {
pub limit: Option<usize>,
}
async fn todos_index(
pagination: Option<Query<Pagination>>,
State(db): State<Db>,
) -> impl IntoResponse {
async fn todos_index(pagination: Query<Pagination>, State(db): State<Db>) -> impl IntoResponse {
let todos = db.read().unwrap();
let Query(pagination) = pagination.unwrap_or_default();
let todos = todos
.values()
.skip(pagination.offset.unwrap_or(0))