mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 14:02:21 -04:00
Update to latest rules_rust and Rust 1.64
This commit is contained in:
parent
9abc73360e
commit
a39a3b4d34
66 changed files with 140 additions and 139 deletions
2
defs.bzl
2
defs.bzl
|
@ -20,7 +20,7 @@ def setup_deps():
|
|||
rust_repositories(
|
||||
edition = "2021",
|
||||
include_rustc_srcs = False,
|
||||
version = "1.58.1",
|
||||
version = "1.64.0",
|
||||
)
|
||||
|
||||
raze_fetch_remote_crates()
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
"""Repo setup that can't happen until after defs.bzl:setup_deps() is run."""
|
||||
|
||||
load("@py_deps//:requirements.bzl", "install_deps")
|
||||
load("@rules_rust//tools/rust_analyzer/raze:crates.bzl", "rules_rust_tools_rust_analyzer_fetch_remote_crates")
|
||||
load("@build_bazel_rules_nodejs//toolchains/esbuild:esbuild_repositories.bzl", "esbuild_repositories")
|
||||
|
||||
def setup_late_deps():
|
||||
install_deps()
|
||||
rules_rust_tools_rust_analyzer_fetch_remote_crates()
|
||||
esbuild_repositories()
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
// Copyright: Ankitects Pty Ltd and contributors
|
||||
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||
|
||||
// Can remove after update to pyo3 0.17
|
||||
#![allow(clippy::borrow_deref_ref)]
|
||||
|
||||
use anki::backend::{init_backend, Backend as RustBackend};
|
||||
use anki::log::default_logger;
|
||||
use pyo3::exceptions::PyException;
|
||||
|
|
|
@ -33,11 +33,11 @@ def register_repos():
|
|||
maybe(
|
||||
http_archive,
|
||||
name = "rules_rust",
|
||||
strip_prefix = "rules_rust-adf2790f3ff063d909acd70aacdd2832756113a5",
|
||||
strip_prefix = "rules_rust-f0cdcedc2a68ffdb3048a8510b380e64eb9a1d72",
|
||||
urls = [
|
||||
"https://github.com/bazelbuild/rules_rust/archive/adf2790f3ff063d909acd70aacdd2832756113a5.zip",
|
||||
"https://github.com/bazelbuild/rules_rust/archive/f0cdcedc2a68ffdb3048a8510b380e64eb9a1d72.zip",
|
||||
],
|
||||
sha256 = "7277e9e58ec157c233fa571e27f684402c1c0711370ef8bf379af63bd31cbe8b",
|
||||
sha256 = "cc14a14ca5df2dd52f7d8b1a545f11cb42e9fae7861b4d5b83e883a8cc0f96bd",
|
||||
)
|
||||
|
||||
# maybe(
|
||||
|
|
|
@ -81,15 +81,11 @@ fn strip_unused_ftl_messages_and_terms(ftl_root: &str, used_ftls: &HashSet<Strin
|
|||
let mut ast = parser::parse(ftl.as_str()).expect("failed to parse ftl");
|
||||
let num_entries = ast.body.len();
|
||||
|
||||
ast.body = ast
|
||||
.body
|
||||
.into_iter()
|
||||
.filter(|entry| match entry {
|
||||
ast::Entry::Message(msg) => used_ftls.contains(msg.id.name),
|
||||
ast::Entry::Term(term) => used_ftls.contains(term.id.name),
|
||||
_ => true,
|
||||
})
|
||||
.collect();
|
||||
ast.body.retain(|entry| match entry {
|
||||
ast::Entry::Message(msg) => used_ftls.contains(msg.id.name),
|
||||
ast::Entry::Term(term) => used_ftls.contains(term.id.name),
|
||||
_ => true,
|
||||
});
|
||||
|
||||
if ast.body.len() < num_entries {
|
||||
fs::write(entry.path(), serialize::serialize(&ast)).expect("failed to write file");
|
||||
|
|
|
@ -377,13 +377,13 @@ fn is_select_expr<'s, S: Slice<'s>>(expr: &Expression<S>) -> bool {
|
|||
match expr {
|
||||
Expression::Select { .. } => true,
|
||||
Expression::Inline(InlineExpression::Placeable { expression }) => {
|
||||
is_select_expr(&*expression)
|
||||
is_select_expr(expression)
|
||||
}
|
||||
Expression::Inline(_) => false,
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Default, Copy, Clone, PartialEq)]
|
||||
#[derive(Debug, Default, Copy, Clone, PartialEq, Eq)]
|
||||
pub struct Options {
|
||||
pub with_junk: bool,
|
||||
}
|
||||
|
|
|
@ -133,7 +133,7 @@ impl Backend {
|
|||
let guard = self.col.lock().unwrap();
|
||||
guard
|
||||
.is_some()
|
||||
.then(|| guard)
|
||||
.then_some(guard)
|
||||
.ok_or(AnkiError::CollectionNotOpen)
|
||||
}
|
||||
|
||||
|
@ -141,7 +141,7 @@ impl Backend {
|
|||
let guard = self.col.lock().unwrap();
|
||||
guard
|
||||
.is_none()
|
||||
.then(|| guard)
|
||||
.then_some(guard)
|
||||
.ok_or(AnkiError::CollectionAlreadyOpen)
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ use crate::{
|
|||
text::html_to_text_line,
|
||||
};
|
||||
|
||||
#[derive(Debug, PartialEq, Clone, Copy, Display, EnumIter, EnumString)]
|
||||
#[derive(Debug, PartialEq, Eq, Clone, Copy, Display, EnumIter, EnumString)]
|
||||
#[strum(serialize_all = "camelCase")]
|
||||
pub enum Column {
|
||||
#[strum(serialize = "")]
|
||||
|
|
|
@ -30,7 +30,7 @@ impl CardId {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize_repr, Deserialize_repr, Debug, PartialEq, TryFromPrimitive, Clone, Copy)]
|
||||
#[derive(Serialize_repr, Deserialize_repr, Debug, PartialEq, Eq, TryFromPrimitive, Clone, Copy)]
|
||||
#[repr(u8)]
|
||||
pub enum CardType {
|
||||
New = 0,
|
||||
|
@ -39,7 +39,7 @@ pub enum CardType {
|
|||
Relearn = 3,
|
||||
}
|
||||
|
||||
#[derive(Serialize_repr, Deserialize_repr, Debug, PartialEq, TryFromPrimitive, Clone, Copy)]
|
||||
#[derive(Serialize_repr, Deserialize_repr, Debug, PartialEq, Eq, TryFromPrimitive, Clone, Copy)]
|
||||
#[repr(i8)]
|
||||
pub enum CardQueue {
|
||||
/// due is the order cards are shown in
|
||||
|
@ -58,7 +58,7 @@ pub enum CardQueue {
|
|||
UserBuried = -3,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct Card {
|
||||
pub(crate) id: CardId,
|
||||
pub(crate) note_id: NoteId,
|
||||
|
@ -177,7 +177,7 @@ impl Card {
|
|||
.unwrap_or(new_steps.len())
|
||||
// (re)learning card must have at least 1 step remaining
|
||||
.max(1) as u32;
|
||||
(remaining != new_remaining).then(|| new_remaining)
|
||||
(remaining != new_remaining).then_some(new_remaining)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ struct TtsDirective<'a> {
|
|||
options: HashMap<&'a str, &'a str>,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
struct OtherDirective<'a> {
|
||||
name: &'a str,
|
||||
content: &'a str,
|
||||
|
|
|
@ -119,7 +119,7 @@ fn datetime_from_file_name(file_name: &str) -> Option<DateTime<Local>> {
|
|||
.and_then(|datetime| Local.from_local_datetime(&datetime).latest())
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Clone)]
|
||||
#[derive(Debug, PartialEq, Eq, Clone)]
|
||||
struct Backup {
|
||||
path: PathBuf,
|
||||
datetime: DateTime<Local>,
|
||||
|
@ -167,7 +167,7 @@ struct BackupFilter {
|
|||
obsolete: Vec<Backup>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
enum BackupStage {
|
||||
Daily,
|
||||
Weekly,
|
||||
|
|
|
@ -67,7 +67,7 @@ pub(crate) enum ConfigKey {
|
|||
SchedulerVersion,
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Serialize_repr, Deserialize_repr, Clone, Copy, Debug)]
|
||||
#[derive(PartialEq, Eq, Serialize_repr, Deserialize_repr, Clone, Copy, Debug)]
|
||||
#[repr(u8)]
|
||||
pub enum SchedulerVersion {
|
||||
V1 = 1,
|
||||
|
@ -298,7 +298,7 @@ impl Default for NewReviewMix {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Serialize_repr, Deserialize_repr, Clone, Copy)]
|
||||
#[derive(PartialEq, Eq, Serialize_repr, Deserialize_repr, Clone, Copy)]
|
||||
#[repr(u8)]
|
||||
pub(crate) enum Weekday {
|
||||
Sunday = 0,
|
||||
|
|
|
@ -14,7 +14,7 @@ pub enum I32ConfigKey {
|
|||
impl Collection {
|
||||
pub fn get_config_i32(&self, key: I32ConfigKey) -> i32 {
|
||||
#[allow(clippy::match_single_binding)]
|
||||
self.get_config_optional(key).unwrap_or_else(|| match key {
|
||||
self.get_config_optional(key).unwrap_or(match key {
|
||||
_other => 0,
|
||||
})
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ use crate::{
|
|||
timestamp::{TimestampMillis, TimestampSecs},
|
||||
};
|
||||
|
||||
#[derive(Debug, Default, PartialEq)]
|
||||
#[derive(Debug, Default, PartialEq, Eq)]
|
||||
pub struct CheckDatabaseOutput {
|
||||
card_properties_invalid: usize,
|
||||
card_position_too_high: usize,
|
||||
|
|
|
@ -80,7 +80,7 @@ pub struct NewConfSchema11 {
|
|||
other: HashMap<String, Value>,
|
||||
}
|
||||
|
||||
#[derive(Serialize_tuple, Debug, PartialEq, Clone)]
|
||||
#[derive(Serialize_tuple, Debug, PartialEq, Eq, Clone)]
|
||||
pub struct NewCardIntervals {
|
||||
good: u16,
|
||||
easy: u16,
|
||||
|
@ -120,7 +120,7 @@ where
|
|||
.unwrap_or_default())
|
||||
}
|
||||
|
||||
#[derive(Serialize_repr, Deserialize_repr, Debug, PartialEq, Clone)]
|
||||
#[derive(Serialize_repr, Deserialize_repr, Debug, PartialEq, Eq, Clone)]
|
||||
#[repr(u8)]
|
||||
pub enum NewCardOrderSchema11 {
|
||||
Random = 0,
|
||||
|
@ -154,7 +154,7 @@ pub struct RevConfSchema11 {
|
|||
other: HashMap<String, Value>,
|
||||
}
|
||||
|
||||
#[derive(Serialize_repr, Deserialize_repr, Debug, PartialEq, Clone)]
|
||||
#[derive(Serialize_repr, Deserialize_repr, Debug, PartialEq, Eq, Clone)]
|
||||
#[repr(u8)]
|
||||
pub enum LeechAction {
|
||||
Suspend = 0,
|
||||
|
|
|
@ -38,11 +38,11 @@ impl NormalDeck {
|
|||
|
||||
impl DayLimit {
|
||||
pub fn limit(&self, today: u32) -> Option<u32> {
|
||||
(self.today == today).then(|| self.limit)
|
||||
(self.today == today).then_some(self.limit)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub(crate) struct RemainingLimits {
|
||||
pub review: u32,
|
||||
pub new: u32,
|
||||
|
|
|
@ -6,7 +6,7 @@ use itertools::Itertools;
|
|||
|
||||
use crate::{prelude::*, text::normalize_to_nfc};
|
||||
|
||||
#[derive(Debug, Clone, Default, PartialEq)]
|
||||
#[derive(Debug, Clone, Default, PartialEq, Eq)]
|
||||
pub struct NativeDeckName(String);
|
||||
|
||||
impl NativeDeckName {
|
||||
|
@ -242,7 +242,7 @@ mod test {
|
|||
fn drag_drop() {
|
||||
// use custom separator to make the tests easier to read
|
||||
fn n(s: &str) -> NativeDeckName {
|
||||
NativeDeckName(s.replace(":", "\x1f"))
|
||||
NativeDeckName(s.replace(':', "\x1f"))
|
||||
}
|
||||
|
||||
#[allow(clippy::unnecessary_wraps)]
|
||||
|
|
|
@ -77,7 +77,7 @@ fn is_false(b: &bool) -> bool {
|
|||
!b
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
|
||||
#[derive(Serialize, Deserialize, PartialEq, Eq, Debug, Clone)]
|
||||
pub struct DeckCommonSchema11 {
|
||||
#[serde(deserialize_with = "deserialize_number_from_string")]
|
||||
pub(crate) id: DeckId,
|
||||
|
@ -105,7 +105,7 @@ pub struct DeckCommonSchema11 {
|
|||
other: HashMap<String, Value>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
|
||||
#[derive(Serialize, Deserialize, PartialEq, Eq, Debug, Clone)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct NormalDeckSchema11 {
|
||||
#[serde(flatten)]
|
||||
|
@ -149,7 +149,7 @@ pub struct FilteredDeckSchema11 {
|
|||
#[serde(default)]
|
||||
preview_delay: u32,
|
||||
}
|
||||
#[derive(Serialize, Deserialize, Debug, PartialEq, Default, Clone)]
|
||||
#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Default, Clone)]
|
||||
pub struct DeckTodaySchema11 {
|
||||
#[serde(rename = "lrnToday")]
|
||||
pub(crate) lrn: TodayAmountSchema11,
|
||||
|
@ -161,7 +161,7 @@ pub struct DeckTodaySchema11 {
|
|||
pub(crate) time: TodayAmountSchema11,
|
||||
}
|
||||
|
||||
#[derive(Serialize_tuple, Deserialize, Debug, PartialEq, Default, Clone)]
|
||||
#[derive(Serialize_tuple, Deserialize, Debug, PartialEq, Eq, Default, Clone)]
|
||||
#[serde(from = "Vec<Value>")]
|
||||
pub struct TodayAmountSchema11 {
|
||||
day: i32,
|
||||
|
@ -178,7 +178,7 @@ impl From<Vec<Value>> for TodayAmountSchema11 {
|
|||
}
|
||||
}
|
||||
}
|
||||
#[derive(Serialize_tuple, Deserialize, Debug, PartialEq, Clone)]
|
||||
#[derive(Serialize_tuple, Deserialize, Debug, PartialEq, Eq, Clone)]
|
||||
pub struct FilteredSearchTermSchema11 {
|
||||
search: String,
|
||||
#[serde(deserialize_with = "deserialize_number_from_string")]
|
||||
|
|
|
@ -8,13 +8,13 @@ use rusqlite::{types::FromSqlError, Error};
|
|||
|
||||
use super::AnkiError;
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub struct DbError {
|
||||
pub info: String,
|
||||
pub kind: DbErrorKind,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub enum DbErrorKind {
|
||||
FileTooNew,
|
||||
FileTooOld,
|
||||
|
|
|
@ -5,7 +5,7 @@ use anki_i18n::I18n;
|
|||
|
||||
use super::AnkiError;
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub enum FilteredDeckError {
|
||||
MustBeLeafNode,
|
||||
CanNotMoveCardsInto,
|
||||
|
@ -33,7 +33,7 @@ impl From<FilteredDeckError> for AnkiError {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub enum CustomStudyError {
|
||||
NoMatchingCards,
|
||||
ExistingDeck,
|
||||
|
|
|
@ -18,7 +18,7 @@ use crate::{i18n::I18n, links::HelpPage};
|
|||
|
||||
pub type Result<T, E = AnkiError> = std::result::Result<T, E>;
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub enum AnkiError {
|
||||
InvalidInput(String),
|
||||
TemplateError(String),
|
||||
|
@ -138,7 +138,7 @@ impl AnkiError {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub enum TemplateError {
|
||||
NoClosingBrackets(String),
|
||||
ConditionalNotClosed(String),
|
||||
|
@ -195,14 +195,14 @@ impl From<csv::Error> for AnkiError {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub struct CardTypeError {
|
||||
pub notetype: String,
|
||||
pub ordinal: usize,
|
||||
pub details: CardTypeErrorDetails,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub enum CardTypeErrorDetails {
|
||||
TemplateError,
|
||||
Duplicate(usize),
|
||||
|
@ -212,7 +212,7 @@ pub enum CardTypeErrorDetails {
|
|||
ExtraneousCloze,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Clone)]
|
||||
#[derive(Debug, PartialEq, Eq, Clone)]
|
||||
pub enum ImportError {
|
||||
Corrupt,
|
||||
TooNew,
|
||||
|
@ -232,7 +232,7 @@ impl ImportError {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Clone)]
|
||||
#[derive(Debug, PartialEq, Eq, Clone)]
|
||||
|
||||
pub struct FileIoError {
|
||||
pub path: String,
|
||||
|
|
|
@ -6,13 +6,13 @@ use reqwest::StatusCode;
|
|||
|
||||
use super::AnkiError;
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub struct NetworkError {
|
||||
pub info: String,
|
||||
pub kind: NetworkErrorKind,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub enum NetworkErrorKind {
|
||||
Offline,
|
||||
Timeout,
|
||||
|
@ -20,13 +20,13 @@ pub enum NetworkErrorKind {
|
|||
Other,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub struct SyncError {
|
||||
pub info: String,
|
||||
pub kind: SyncErrorKind,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub enum SyncErrorKind {
|
||||
Conflict,
|
||||
ServerError,
|
||||
|
|
|
@ -8,13 +8,13 @@ use nom::error::{ErrorKind as NomErrorKind, ParseError as NomParseError};
|
|||
|
||||
use super::AnkiError;
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub enum ParseError<'a> {
|
||||
Anki(&'a str, SearchErrorKind),
|
||||
Nom(&'a str, NomErrorKind),
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub enum SearchErrorKind {
|
||||
MisplacedAnd,
|
||||
MisplacedOr,
|
||||
|
|
|
@ -124,14 +124,18 @@ impl ExchangeData {
|
|||
|
||||
fn check_ids(&self) -> Result<()> {
|
||||
let now = TimestampMillis::now().0;
|
||||
self.cards
|
||||
if self
|
||||
.cards
|
||||
.iter()
|
||||
.map(|card| card.id.0)
|
||||
.chain(self.notes.iter().map(|note| note.id.0))
|
||||
.chain(self.revlog.iter().map(|entry| entry.id.0))
|
||||
.any(|timestamp| timestamp > now)
|
||||
.then(|| Err(AnkiError::InvalidId))
|
||||
.unwrap_or(Ok(()))
|
||||
{
|
||||
Err(AnkiError::InvalidId)
|
||||
} else {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ use crate::{
|
|||
},
|
||||
};
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum ImportProgress {
|
||||
File,
|
||||
Extracting,
|
||||
|
@ -27,7 +27,7 @@ pub enum ImportProgress {
|
|||
Notes(usize),
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum ExportProgress {
|
||||
File,
|
||||
Gathering,
|
||||
|
|
|
@ -263,7 +263,7 @@ impl<'n> NoteContext<'n> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn replace_media_refs(&mut self, field: &mut String) -> Option<String> {
|
||||
fn replace_media_refs(&mut self, field: &mut str) -> Option<String> {
|
||||
replace_media_refs(field, |name| {
|
||||
if let Ok(normalized) = safe_normalized_file_name(name) {
|
||||
if let Some(entry) = self.media_map.use_entry(&normalized) {
|
||||
|
|
|
@ -71,7 +71,7 @@ fn check_collection_and_mod_schema(col_path: &Path) -> Result<()> {
|
|||
.pragma_query_value(None, "integrity_check", |row| row.get::<_, String>(0))
|
||||
.ok()
|
||||
})
|
||||
.and_then(|s| (s == "ok").then(|| ()))
|
||||
.and_then(|s| (s == "ok").then_some(()))
|
||||
.ok_or(AnkiError::ImportError(ImportError::Corrupt))
|
||||
}
|
||||
|
||||
|
|
|
@ -211,7 +211,7 @@ impl NoteContext {
|
|||
}
|
||||
|
||||
fn guid_column(&self) -> Option<usize> {
|
||||
self.with_guid.then(|| 1)
|
||||
self.with_guid.then_some(1)
|
||||
}
|
||||
|
||||
fn notetype_column(&self) -> Option<usize> {
|
||||
|
|
|
@ -61,7 +61,7 @@ impl CsvMetadata {
|
|||
CsvNotetype::GlobalNotetype(global) => global
|
||||
.field_columns
|
||||
.iter()
|
||||
.map(|&i| (i > 0).then(|| i as usize))
|
||||
.map(|&i| (i > 0).then_some(i as usize))
|
||||
.collect(),
|
||||
CsvNotetype::NotetypeColumn(_) => {
|
||||
let meta_columns = self.meta_columns();
|
||||
|
@ -124,8 +124,8 @@ struct ColumnContext {
|
|||
impl ColumnContext {
|
||||
fn new(metadata: &CsvMetadata) -> Result<Self> {
|
||||
Ok(Self {
|
||||
tags_column: (metadata.tags_column > 0).then(|| metadata.tags_column as usize),
|
||||
guid_column: (metadata.guid_column > 0).then(|| metadata.guid_column as usize),
|
||||
tags_column: (metadata.tags_column > 0).then_some(metadata.tags_column as usize),
|
||||
guid_column: (metadata.guid_column > 0).then_some(metadata.guid_column as usize),
|
||||
deck_column: metadata.deck()?.column(),
|
||||
notetype_column: metadata.notetype()?.column(),
|
||||
field_source_columns: metadata.field_source_columns()?,
|
||||
|
|
|
@ -404,12 +404,9 @@ fn maybe_set_tags_column(metadata: &mut CsvMetadata, meta_columns: &HashSet<usiz
|
|||
|
||||
fn delimiter_from_value(value: &str) -> Option<Delimiter> {
|
||||
let normed = value.to_ascii_lowercase();
|
||||
for delimiter in Delimiter::iter() {
|
||||
if normed.trim() == delimiter.name() || normed.as_bytes() == [delimiter.byte()] {
|
||||
return Some(delimiter);
|
||||
}
|
||||
}
|
||||
None
|
||||
Delimiter::iter().find(|&delimiter| {
|
||||
normed.trim() == delimiter.name() || normed.as_bytes() == [delimiter.byte()]
|
||||
})
|
||||
}
|
||||
|
||||
fn delimiter_from_reader(mut reader: impl Read) -> Result<Delimiter> {
|
||||
|
|
|
@ -22,7 +22,7 @@ pub struct ForeignData {
|
|||
updated_tags: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize, Deserialize)]
|
||||
#[serde(default)]
|
||||
pub struct ForeignNote {
|
||||
guid: String,
|
||||
|
@ -43,7 +43,7 @@ pub struct ForeignCard {
|
|||
pub lapses: u32,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct ForeignNotetype {
|
||||
name: String,
|
||||
fields: Vec<String>,
|
||||
|
@ -52,7 +52,7 @@ pub struct ForeignNotetype {
|
|||
is_cloze: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct ForeignTemplate {
|
||||
name: String,
|
||||
qfmt: String,
|
||||
|
|
|
@ -33,7 +33,7 @@ pub(crate) fn contains_latex(text: &str) -> bool {
|
|||
LATEX.is_match(text)
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub struct ExtractedLatex {
|
||||
pub fname: String,
|
||||
pub latex: String,
|
||||
|
|
|
@ -27,7 +27,7 @@ use crate::{
|
|||
text::{extract_media_refs, normalize_to_nfc, MediaRef, REMOTE_FILENAME},
|
||||
};
|
||||
|
||||
#[derive(Debug, PartialEq, Clone)]
|
||||
#[derive(Debug, PartialEq, Eq, Clone)]
|
||||
pub struct MediaCheckOutput {
|
||||
pub unused: Vec<String>,
|
||||
pub missing: Vec<String>,
|
||||
|
@ -38,7 +38,7 @@ pub struct MediaCheckOutput {
|
|||
pub trash_bytes: u64,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Default)]
|
||||
#[derive(Debug, PartialEq, Eq, Default)]
|
||||
struct MediaFolderCheck {
|
||||
files: Vec<String>,
|
||||
renamed: HashMap<String, String>,
|
||||
|
|
|
@ -43,7 +43,7 @@ fn initial_db_setup(db: &mut Connection) -> Result<()> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub struct MediaEntry {
|
||||
pub fname: String,
|
||||
/// If None, file has been deleted
|
||||
|
@ -54,7 +54,7 @@ pub struct MediaEntry {
|
|||
pub sync_required: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub struct MediaDatabaseMetadata {
|
||||
/// The syncing code no longer uses this; files are scanned for
|
||||
/// indiscriminately. After this has been in production for a while
|
||||
|
|
|
@ -79,7 +79,7 @@ enum LocalState {
|
|||
InDbAndPending,
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Debug)]
|
||||
#[derive(PartialEq, Eq, Debug)]
|
||||
enum RequiredChange {
|
||||
// none also covers the case where we'll later upload
|
||||
None,
|
||||
|
|
|
@ -37,7 +37,7 @@ pub(crate) struct TransformNoteOutput {
|
|||
pub update_tags: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Clone)]
|
||||
#[derive(Debug, PartialEq, Eq, Clone)]
|
||||
pub struct Note {
|
||||
pub id: NoteId,
|
||||
pub guid: String,
|
||||
|
@ -108,7 +108,7 @@ impl Collection {
|
|||
|
||||
/// Information required for updating tags while leaving note content alone.
|
||||
/// Tags are stored in their DB form, separated by spaces.
|
||||
#[derive(Debug, PartialEq, Clone)]
|
||||
#[derive(Debug, PartialEq, Eq, Clone)]
|
||||
pub(crate) struct NoteTags {
|
||||
pub id: NoteId,
|
||||
pub mtime: TimestampSecs,
|
||||
|
@ -747,7 +747,7 @@ mod test {
|
|||
col.storage.db_scalar::<u32>("select count() from graves")?,
|
||||
0
|
||||
);
|
||||
assert!(!col.get_next_card()?.is_some());
|
||||
assert!(col.get_next_card()?.is_none());
|
||||
Ok(())
|
||||
};
|
||||
|
||||
|
@ -786,7 +786,7 @@ mod test {
|
|||
col.storage.db_scalar::<u32>("select count() from graves")?,
|
||||
3
|
||||
);
|
||||
assert!(!col.get_next_card()?.is_some());
|
||||
assert!(col.get_next_card()?.is_none());
|
||||
Ok(())
|
||||
};
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ use crate::{
|
|||
};
|
||||
|
||||
/// Info about an existing card required when generating new cards
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub(crate) struct AlreadyGeneratedCardInfo {
|
||||
pub id: CardId,
|
||||
pub nid: NoteId,
|
||||
|
@ -178,7 +178,7 @@ pub(super) fn group_generated_cards_by_note(
|
|||
out
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Default)]
|
||||
#[derive(Debug, PartialEq, Eq, Default)]
|
||||
pub(crate) struct ExtractedCardInfo {
|
||||
// if set, the due position new cards should be given
|
||||
pub due: Option<u32>,
|
||||
|
|
|
@ -14,7 +14,7 @@ use crate::{
|
|||
text::{HTML_MEDIA_TAGS, SOUND_TAG},
|
||||
};
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
struct Template<'a> {
|
||||
notetype: &'a str,
|
||||
card_type: &'a str,
|
||||
|
|
|
@ -33,7 +33,7 @@ pub struct NotetypeChangeInfo {
|
|||
pub new_template_names: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub struct TemplateMap {
|
||||
pub removed: Vec<usize>,
|
||||
pub remapped: HashMap<usize, usize>,
|
||||
|
|
|
@ -20,7 +20,7 @@ use crate::{
|
|||
types::Usn,
|
||||
};
|
||||
|
||||
#[derive(Serialize_repr, Deserialize_repr, PartialEq, Debug, Clone)]
|
||||
#[derive(Serialize_repr, Deserialize_repr, PartialEq, Eq, Debug, Clone)]
|
||||
#[repr(u8)]
|
||||
pub enum NotetypeKind {
|
||||
Standard = 0,
|
||||
|
|
|
@ -20,7 +20,7 @@ fn ords_changed(ords: &[Option<u32>], previous_len: usize) -> bool {
|
|||
.any(|(idx, &ord)| ord != Some(idx as u32))
|
||||
}
|
||||
|
||||
#[derive(Default, PartialEq, Debug)]
|
||||
#[derive(Default, PartialEq, Eq, Debug)]
|
||||
struct TemplateOrdChanges {
|
||||
added: Vec<u32>,
|
||||
removed: Vec<u16>,
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
use crate::prelude::*;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub enum Op {
|
||||
Custom(String),
|
||||
AddDeck,
|
||||
|
@ -95,7 +95,7 @@ impl Op {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Default, Clone, Copy)]
|
||||
#[derive(Debug, PartialEq, Eq, Default, Clone, Copy)]
|
||||
pub struct StateChanges {
|
||||
pub card: bool,
|
||||
pub note: bool,
|
||||
|
@ -107,13 +107,13 @@ pub struct StateChanges {
|
|||
pub mtime: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Clone)]
|
||||
#[derive(Debug, PartialEq, Eq, Clone)]
|
||||
pub struct OpChanges {
|
||||
pub op: Op,
|
||||
pub changes: StateChanges,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub struct OpOutput<T> {
|
||||
pub output: T,
|
||||
pub changes: OpChanges,
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
macro_rules! protobuf {
|
||||
($ident:ident) => {
|
||||
pub mod $ident {
|
||||
#![allow(clippy::derive_partial_eq_without_eq)]
|
||||
include!(concat!(
|
||||
env!("OUT_DIR"),
|
||||
concat!("/anki.", stringify!($ident), ".rs")
|
||||
|
|
|
@ -32,7 +32,7 @@ impl From<TimestampMillis> for RevlogId {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize_tuple, Deserialize, Debug, Default, PartialEq)]
|
||||
#[derive(Serialize_tuple, Deserialize, Debug, Default, PartialEq, Eq)]
|
||||
pub struct RevlogEntry {
|
||||
pub id: RevlogId,
|
||||
pub cid: CardId,
|
||||
|
@ -57,7 +57,7 @@ pub struct RevlogEntry {
|
|||
pub review_kind: RevlogReviewKind,
|
||||
}
|
||||
|
||||
#[derive(Serialize_repr, Deserialize_repr, Debug, PartialEq, TryFromPrimitive, Clone, Copy)]
|
||||
#[derive(Serialize_repr, Deserialize_repr, Debug, PartialEq, Eq, TryFromPrimitive, Clone, Copy)]
|
||||
#[repr(u8)]
|
||||
pub enum RevlogReviewKind {
|
||||
Learning = 0,
|
||||
|
|
|
@ -19,9 +19,11 @@ use crate::{
|
|||
|
||||
impl Card {
|
||||
pub(crate) fn original_or_current_due(&self) -> i32 {
|
||||
self.is_filtered()
|
||||
.then(|| self.original_due)
|
||||
.unwrap_or(self.due)
|
||||
if self.is_filtered() {
|
||||
self.original_due
|
||||
} else {
|
||||
self.due
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn last_position(&self) -> Option<u32> {
|
||||
|
@ -77,7 +79,7 @@ pub(crate) struct NewCardSorter {
|
|||
position: HashMap<NoteId, u32>,
|
||||
}
|
||||
|
||||
#[derive(PartialEq)]
|
||||
#[derive(PartialEq, Eq)]
|
||||
pub enum NewCardDueOrder {
|
||||
NoteId,
|
||||
Random,
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
use super::{LearningQueueEntry, MainQueueEntry, MainQueueEntryKind};
|
||||
use crate::{card::CardQueue, prelude::*};
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub(crate) enum QueueEntry {
|
||||
IntradayLearning(LearningQueueEntry),
|
||||
Main(MainQueueEntry),
|
||||
|
@ -37,7 +37,7 @@ impl QueueEntry {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub enum QueueEntryKind {
|
||||
New,
|
||||
Learning,
|
||||
|
|
|
@ -4,14 +4,14 @@
|
|||
use super::CardQueues;
|
||||
use crate::prelude::*;
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub(crate) struct MainQueueEntry {
|
||||
pub id: CardId,
|
||||
pub mtime: TimestampSecs,
|
||||
pub kind: MainQueueEntryKind,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub(crate) enum MainQueueEntryKind {
|
||||
New,
|
||||
Review,
|
||||
|
|
|
@ -146,7 +146,7 @@ mod test {
|
|||
let deck = col.get_deck(DeckId(1))?.unwrap();
|
||||
assert_eq!(deck.common.review_studied, 1);
|
||||
|
||||
assert!(!col.get_next_card()?.is_some());
|
||||
assert!(col.get_next_card()?.is_none());
|
||||
|
||||
Ok(())
|
||||
};
|
||||
|
|
|
@ -55,7 +55,7 @@ impl Card {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub struct DueDateSpecifier {
|
||||
min: u32,
|
||||
max: u32,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright: Ankitects Pty Ltd and contributors
|
||||
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub(crate) enum IntervalKind {
|
||||
InSecs(u32),
|
||||
InDays(u32),
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
use super::{interval_kind::IntervalKind, CardState, ReviewState, SchedulingStates, StateContext};
|
||||
use crate::revlog::RevlogReviewKind;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub struct LearnState {
|
||||
pub remaining_steps: u32,
|
||||
pub scheduled_secs: u32,
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
use super::interval_kind::IntervalKind;
|
||||
use crate::revlog::RevlogReviewKind;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Default)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
|
||||
pub struct NewState {
|
||||
pub position: u32,
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
use super::{IntervalKind, SchedulingStates, StateContext};
|
||||
use crate::revlog::RevlogReviewKind;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub struct PreviewState {
|
||||
pub scheduled_secs: u32,
|
||||
pub finished: bool,
|
||||
|
|
|
@ -5,7 +5,7 @@ use chrono::{Date, Duration, FixedOffset, Local, TimeZone, Timelike};
|
|||
|
||||
use crate::prelude::*;
|
||||
|
||||
#[derive(Debug, PartialEq, Clone, Copy)]
|
||||
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
|
||||
pub struct SchedTimingToday {
|
||||
pub now: TimestampSecs,
|
||||
/// The number of days that have passed since the collection was created.
|
||||
|
|
|
@ -25,13 +25,13 @@ use crate::{
|
|||
prelude::AnkiError,
|
||||
};
|
||||
|
||||
#[derive(Debug, PartialEq, Clone, Copy)]
|
||||
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
|
||||
pub enum ReturnItemType {
|
||||
Cards,
|
||||
Notes,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Clone)]
|
||||
#[derive(Debug, PartialEq, Eq, Clone)]
|
||||
pub enum SortMode {
|
||||
NoOrder,
|
||||
Builtin { column: Column, reverse: bool },
|
||||
|
|
|
@ -97,7 +97,7 @@ pub enum PropertyKind {
|
|||
Rated(i32, RatingKind),
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Clone)]
|
||||
#[derive(Debug, PartialEq, Eq, Clone)]
|
||||
pub enum StateKind {
|
||||
New,
|
||||
Review,
|
||||
|
@ -109,13 +109,13 @@ pub enum StateKind {
|
|||
Suspended,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Clone)]
|
||||
#[derive(Debug, PartialEq, Eq, Clone)]
|
||||
pub enum TemplateKind {
|
||||
Ordinal(u16),
|
||||
Name(String),
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Clone)]
|
||||
#[derive(Debug, PartialEq, Eq, Clone)]
|
||||
pub enum RatingKind {
|
||||
AnswerButton(u8),
|
||||
AnyAnswerButton,
|
||||
|
|
|
@ -612,7 +612,7 @@ impl SqlWriter<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Clone, Copy)]
|
||||
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
|
||||
pub enum RequiredTable {
|
||||
Notes,
|
||||
Cards,
|
||||
|
|
|
@ -73,7 +73,7 @@ mod test {
|
|||
|
||||
use super::*;
|
||||
|
||||
#[derive(Deserialize, Debug, PartialEq)]
|
||||
#[derive(Deserialize, Debug, PartialEq, Eq)]
|
||||
struct MaybeInvalid {
|
||||
#[serde(deserialize_with = "default_on_invalid", default)]
|
||||
field: Option<usize>,
|
||||
|
|
|
@ -34,7 +34,7 @@ mod test {
|
|||
// temporary test of fluent term handling
|
||||
let tr = I18n::template_only();
|
||||
assert_eq!(
|
||||
&studied_today(3, 13.0, &tr).replace("\n", " "),
|
||||
&studied_today(3, 13.0, &tr).replace('\n', " "),
|
||||
"Studied 3 cards in 13 seconds today (4.33s/card)"
|
||||
);
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ use serde_json::Value;
|
|||
use crate::{prelude::*, serde::default_on_invalid};
|
||||
|
||||
/// Helper for serdeing the card data column.
|
||||
#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize, Deserialize)]
|
||||
#[serde(default)]
|
||||
pub(crate) struct CardData {
|
||||
#[serde(
|
||||
|
|
|
@ -21,7 +21,7 @@ use std::fmt::Write;
|
|||
pub(crate) use sqlite::SqliteStorage;
|
||||
pub(crate) use sync::open_and_check_sqlite_file;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub(crate) enum SchemaVersion {
|
||||
V11,
|
||||
V18,
|
||||
|
|
|
@ -46,7 +46,7 @@ pub struct NormalSyncProgress {
|
|||
pub remote_remove: usize,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum SyncStage {
|
||||
Connecting,
|
||||
Syncing,
|
||||
|
@ -176,14 +176,14 @@ pub struct SanityCheckResponse {
|
|||
pub server: Option<SanityCheckCounts>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, PartialEq)]
|
||||
#[derive(Serialize, Deserialize, Debug, PartialEq, Eq)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub enum SanityCheckStatus {
|
||||
Ok,
|
||||
Bad,
|
||||
}
|
||||
|
||||
#[derive(Serialize_tuple, Deserialize, Debug, PartialEq)]
|
||||
#[derive(Serialize_tuple, Deserialize, Debug, PartialEq, Eq)]
|
||||
pub struct SanityCheckCounts {
|
||||
pub counts: SanityCheckDueCounts,
|
||||
pub cards: u32,
|
||||
|
@ -196,7 +196,7 @@ pub struct SanityCheckCounts {
|
|||
pub deck_config: u32,
|
||||
}
|
||||
|
||||
#[derive(Serialize_tuple, Deserialize, Debug, Default, PartialEq)]
|
||||
#[derive(Serialize_tuple, Deserialize, Debug, Default, PartialEq, Eq)]
|
||||
pub struct SanityCheckDueCounts {
|
||||
pub new: u32,
|
||||
pub learn: u32,
|
||||
|
@ -209,7 +209,7 @@ pub struct FullSyncProgress {
|
|||
pub total_bytes: usize,
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Debug, Clone, Copy)]
|
||||
#[derive(PartialEq, Eq, Debug, Clone, Copy)]
|
||||
pub enum SyncActionRequired {
|
||||
NoChanges,
|
||||
FullSyncRequired { upload_ok: bool, download_ok: bool },
|
||||
|
|
|
@ -17,7 +17,7 @@ use unicase::UniCase;
|
|||
|
||||
use crate::prelude::*;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct Tag {
|
||||
pub name: String,
|
||||
pub usn: Usn,
|
||||
|
|
|
@ -175,7 +175,7 @@ fn legacy_tokens(mut data: &str) -> impl Iterator<Item = TemplateResult<Token>>
|
|||
// Parsing
|
||||
//----------------------------------------
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
enum ParsedNode {
|
||||
Text(String),
|
||||
Replacement {
|
||||
|
@ -371,7 +371,7 @@ fn template_is_empty(
|
|||
// Rendering
|
||||
//----------------------------------------
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub enum RenderedNode {
|
||||
Text {
|
||||
text: String,
|
||||
|
@ -632,7 +632,7 @@ fn cloze_is_empty(field_map: &HashMap<&str, Cow<str>>, card_ord: u16) -> bool {
|
|||
// Field requirements
|
||||
//----------------------------------------
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub enum FieldRequirements {
|
||||
Any(HashSet<u16>),
|
||||
All(HashSet<u16>),
|
||||
|
|
|
@ -115,20 +115,20 @@ fn prepare_provided(provided: &str) -> String {
|
|||
normalize_to_nfc(provided).into()
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
enum DiffTokenKind {
|
||||
Good,
|
||||
Bad,
|
||||
Missing,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
struct DiffToken<'a> {
|
||||
kind: DiffTokenKind,
|
||||
text: Cow<'a, str>,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
struct DiffOutput<'a> {
|
||||
provided: Vec<DiffToken<'a>>,
|
||||
expected: Vec<DiffToken<'a>>,
|
||||
|
|
|
@ -30,7 +30,7 @@ impl UndoableOp {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
enum UndoMode {
|
||||
NormalOp,
|
||||
Undoing,
|
||||
|
|
Loading…
Reference in a new issue