Query manager code

This commit is contained in:
micialware committed 2026-08-28 16:52:48 +03:00
1 parent 70aff6ed18
commit a01a29c492
2 files changed
+186 -39

No files matched your search

+39 -1
View File
@@ -1,3 +1,4 @@
use std::cmp::Ordering;
use crate::app::AppState;
use crate::core::srs::{FADE_PER_DAY, MAX_SCORE, OrderMode, WordOpenMode};
use crate::data::{INVALID_ID, Id};
@@ -178,7 +179,7 @@ impl CardStatistics {
}
}
#[derive(Clone, Copy)]
#[derive(Copy)]
pub struct EntityHandle<E> {
pub(crate) id: Id,
pub(crate) real: bool,
@@ -187,6 +188,43 @@ pub struct EntityHandle<E> {
}
impl<T> Clone for EntityHandle<T> {
fn clone(&self) -> Self {
EntityHandle{
id: self.id,
real: self.real,
index: self.index,
_phantom: Default::default(),
}
}
}
impl<T> Eq for EntityHandle<T> {}
impl<T> PartialEq<Self> for EntityHandle<T> {
fn eq(&self, other: &Self) -> bool {
self.real == other.real && self.id == other.id
}
}
impl<T> PartialOrd<Self> for EntityHandle<T> {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(self.cmp(other))
}
}
impl<T> Ord for EntityHandle<T> {
fn cmp(&self, other: &Self) -> Ordering {
if self.real && !other.real {
return Ordering::Less
}
if !self.real && other.real{
return Ordering::Greater
}
self.id.cmp(&other.id)
}
}
pub trait EntityData{
fn id(&self) -> Id;
fn set_id(&mut self, id: Id);