completed 06 ticket management
Some checks failed
CI / build (push) Failing after 1m16s
CI / gravity (push) Has been skipped
CI / is_fresh (push) Successful in 26s
CI / formatter (push) Failing after 17s

This commit is contained in:
2025-04-07 12:12:47 +05:30
parent 199b57aad8
commit 9bc063a05b
5 changed files with 65 additions and 13 deletions

View File

@@ -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};