Anki/rslib/src/scheduler/queue/main.rs
Damien Elmes a90d5aa359 use mixed case for abbreviations in Rust code
So, this is fun. Apparently "DeckId" is considered preferable to the
"DeckID" were were using until now, and the latest clippy will start
warning about it. We could of course disable the warning, but probably
better to bite the bullet and switch to the naming that's generally
considered best.
2021-03-27 19:53:33 +10:00

38 lines
1,022 B
Rust

// Copyright: Ankitects Pty Ltd and contributors
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
use super::CardQueues;
use crate::prelude::*;
#[derive(Clone, Copy, Debug, PartialEq)]
pub(crate) struct MainQueueEntry {
pub id: CardId,
pub mtime: TimestampSecs,
pub kind: MainQueueEntryKind,
}
#[derive(Clone, Copy, Debug, PartialEq)]
pub(crate) enum MainQueueEntryKind {
New,
Review,
}
impl CardQueues {
pub(super) fn next_main_entry(&self) -> Option<MainQueueEntry> {
self.main.front().copied()
}
pub(super) fn pop_main_entry(&mut self, id: CardId) -> Option<MainQueueEntry> {
if let Some(last) = self.main.front() {
if last.id == id {
match last.kind {
MainQueueEntryKind::New => self.counts.new -= 1,
MainQueueEntryKind::Review => self.counts.review -= 1,
}
return self.main.pop_front();
}
}
None
}
}