From: Greg Burri Date: Sat, 26 Oct 2024 10:36:45 +0000 (+0200) Subject: Exercise 07-11 X-Git-Url: http://git.euphorik.ch/?a=commitdiff_plain;h=9316c5635e77a0c9c279cad4f4965d0022bad5d5;p=rust_exercises.git Exercise 07-11 --- diff --git a/exercises/07_threads/11_locks/src/lib.rs b/exercises/07_threads/11_locks/src/lib.rs index b5e6c0d..7a7db1a 100644 --- a/exercises/07_threads/11_locks/src/lib.rs +++ b/exercises/07_threads/11_locks/src/lib.rs @@ -60,7 +60,7 @@ enum Command { }, } -pub fn server(receiver: Receiver) { +fn server(receiver: Receiver) { let mut store = TicketStore::new(); loop { match receiver.recv() { diff --git a/exercises/07_threads/11_locks/src/store.rs b/exercises/07_threads/11_locks/src/store.rs index 9387499..306e662 100644 --- a/exercises/07_threads/11_locks/src/store.rs +++ b/exercises/07_threads/11_locks/src/store.rs @@ -28,13 +28,13 @@ impl TicketStore { description: ticket.description, status: Status::ToDo, }; - todo!(); + self.tickets.insert(id, Arc::new(Mutex::new(ticket))); id } // The `get` method should return a handle to the ticket // which allows the caller to either read or modify the ticket. - pub fn get(&self, id: TicketId) -> Option { - todo!() + pub fn get(&self, id: TicketId) -> Option>> { + self.tickets.get(&id).cloned() } }