mirror of
https://github.com/ankitects/anki.git
synced 2026-01-16 15:29:10 -05:00
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.
38 lines
1,022 B
Rust
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
|
|
}
|
|
}
|