completed 06 ticket management
This commit is contained in:
@@ -13,7 +13,16 @@ pub struct TicketStore {
|
||||
counter: u64,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
impl<'a> IntoIterator for &'a TicketStore {
|
||||
type Item = &'a Ticket;
|
||||
type IntoIter = std::collections::btree_map::Values<'a, TicketId, Ticket>;
|
||||
|
||||
fn into_iter(self) -> Self::IntoIter {
|
||||
self.tickets.values()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Ord, PartialOrd)]
|
||||
pub struct TicketId(u64);
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
@@ -40,7 +49,7 @@ pub enum Status {
|
||||
impl TicketStore {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
tickets: todo!(),
|
||||
tickets: BTreeMap::new(),
|
||||
counter: 0,
|
||||
}
|
||||
}
|
||||
@@ -54,16 +63,16 @@ impl TicketStore {
|
||||
description: ticket.description,
|
||||
status: Status::ToDo,
|
||||
};
|
||||
todo!();
|
||||
self.tickets.insert(id, ticket);
|
||||
id
|
||||
}
|
||||
|
||||
pub fn get(&self, id: TicketId) -> Option<&Ticket> {
|
||||
todo!()
|
||||
self.tickets.get(&id)
|
||||
}
|
||||
|
||||
pub fn get_mut(&mut self, id: TicketId) -> Option<&mut Ticket> {
|
||||
todo!()
|
||||
self.tickets.get_mut(&id)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user