]> git.cworth.org Git - rust-learning/commit
Add a single route at /race
authorCarl Worth <cworth@cworth.org>
Tue, 10 Mar 2026 06:11:05 +0000 (23:11 -0700)
committerCarl Worth <cworth@cworth.org>
Thu, 12 Mar 2026 04:14:58 +0000 (21:14 -0700)
commit9ba9c3c5672f4b0ebd63d47976371698e1381d72
treec1cda3b750d9afd0f61d42e204047a2f56bc43bd
parent74714d369f58c7df9a6fb376ea0f7d82a7b0b5b0
Add a single route at /race

That returns the complete race state, which, for now, is only the name
of the race.

New rust features seen for the first time as of this commit:

  * std::sync::Arc for atomically-reference-counted pointers (with
    thread-safe reference counting as you would expect from the name).

  * "crate::" in 'use' paths to reference the root of the current project

  * impl: For creating functions associated with a struct

  * Destructuring in a function parameter: State(state): State<Arc<AppState>>

  * clone() to carefully give the RaceResponse a string it
    owns. (Note: The rust compiler wouldn't even accept the code
    without this clone(): "cannot move out of an `Arc`)
src/handlers.rs [new file with mode: 0644]
src/main.rs
src/state.rs [new file with mode: 0644]