completed 06 ticket management
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
// TODO: Implement `Index<&TicketId>` and `Index<TicketId>` for `TicketStore`.
|
||||
|
||||
use std::ops::Index;
|
||||
|
||||
use ticket_fields::{TicketDescription, TicketTitle};
|
||||
|
||||
#[derive(Clone)]
|
||||
@@ -58,6 +60,20 @@ impl TicketStore {
|
||||
}
|
||||
}
|
||||
|
||||
impl Index<TicketId> for TicketStore {
|
||||
type Output = Ticket;
|
||||
fn index(&self, index: TicketId) -> &Self::Output {
|
||||
return &self.tickets[index.0 as usize];
|
||||
}
|
||||
}
|
||||
|
||||
impl Index<&TicketId> for TicketStore {
|
||||
type Output = Ticket;
|
||||
fn index(&self, index: &TicketId) -> &Self::Output {
|
||||
return &self.tickets[index.0 as usize];
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::{Status, TicketDraft, TicketStore};
|
||||
|
||||
Reference in New Issue
Block a user