completed 06 ticket management
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
// TODO: Implement `IndexMut<&TicketId>` and `IndexMut<TicketId>` for `TicketStore`.
|
||||
|
||||
use std::ops::Index;
|
||||
use std::ops::{Index, IndexMut};
|
||||
use ticket_fields::{TicketDescription, TicketTitle};
|
||||
|
||||
#[derive(Clone)]
|
||||
@@ -75,6 +75,18 @@ impl Index<&TicketId> for TicketStore {
|
||||
}
|
||||
}
|
||||
|
||||
impl IndexMut<TicketId> for TicketStore {
|
||||
fn index_mut(&mut self, index: TicketId) -> &mut Self::Output {
|
||||
self.tickets.iter_mut().find(|a| a.id == index).unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
impl IndexMut<&TicketId> for TicketStore {
|
||||
fn index_mut(&mut self, index: &TicketId) -> &mut Self::Output {
|
||||
self.tickets.iter_mut().find(|a| a.id == *index).unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::{Status, TicketDraft, TicketStore};
|
||||
|
||||
Reference in New Issue
Block a user