From 9316c5635e77a0c9c279cad4f4965d0022bad5d5 Mon Sep 17 00:00:00 2001 From: Greg Burri Date: Sat, 26 Oct 2024 12:36:45 +0200 Subject: [PATCH] Exercise 07-11 --- exercises/07_threads/11_locks/src/lib.rs | 2 +- exercises/07_threads/11_locks/src/store.rs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) 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() } } -- 2.45.2