Update to latest rules_rust and Rust 1.64

This commit is contained in:
Damien Elmes 2022-09-24 11:12:58 +10:00
parent 9abc73360e
commit a39a3b4d34
66 changed files with 140 additions and 139 deletions

View file

@ -20,7 +20,7 @@ def setup_deps():
rust_repositories( rust_repositories(
edition = "2021", edition = "2021",
include_rustc_srcs = False, include_rustc_srcs = False,
version = "1.58.1", version = "1.64.0",
) )
raze_fetch_remote_crates() raze_fetch_remote_crates()

View file

@ -1,10 +1,8 @@
"""Repo setup that can't happen until after defs.bzl:setup_deps() is run.""" """Repo setup that can't happen until after defs.bzl:setup_deps() is run."""
load("@py_deps//:requirements.bzl", "install_deps") 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") load("@build_bazel_rules_nodejs//toolchains/esbuild:esbuild_repositories.bzl", "esbuild_repositories")
def setup_late_deps(): def setup_late_deps():
install_deps() install_deps()
rules_rust_tools_rust_analyzer_fetch_remote_crates()
esbuild_repositories() esbuild_repositories()

View file

@ -1,6 +1,9 @@
// Copyright: Ankitects Pty Ltd and contributors // Copyright: Ankitects Pty Ltd and contributors
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html // 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::backend::{init_backend, Backend as RustBackend};
use anki::log::default_logger; use anki::log::default_logger;
use pyo3::exceptions::PyException; use pyo3::exceptions::PyException;

View file

@ -33,11 +33,11 @@ def register_repos():
maybe( maybe(
http_archive, http_archive,
name = "rules_rust", name = "rules_rust",
strip_prefix = "rules_rust-adf2790f3ff063d909acd70aacdd2832756113a5", strip_prefix = "rules_rust-f0cdcedc2a68ffdb3048a8510b380e64eb9a1d72",
urls = [ urls = [
"https://github.com/bazelbuild/rules_rust/archive/adf2790f3ff063d909acd70aacdd2832756113a5.zip", "https://github.com/bazelbuild/rules_rust/archive/f0cdcedc2a68ffdb3048a8510b380e64eb9a1d72.zip",
], ],
sha256 = "7277e9e58ec157c233fa571e27f684402c1c0711370ef8bf379af63bd31cbe8b", sha256 = "cc14a14ca5df2dd52f7d8b1a545f11cb42e9fae7861b4d5b83e883a8cc0f96bd",
) )
# maybe( # maybe(

View file

@ -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 mut ast = parser::parse(ftl.as_str()).expect("failed to parse ftl");
let num_entries = ast.body.len(); let num_entries = ast.body.len();
ast.body = ast ast.body.retain(|entry| match entry {
.body
.into_iter()
.filter(|entry| match entry {
ast::Entry::Message(msg) => used_ftls.contains(msg.id.name), ast::Entry::Message(msg) => used_ftls.contains(msg.id.name),
ast::Entry::Term(term) => used_ftls.contains(term.id.name), ast::Entry::Term(term) => used_ftls.contains(term.id.name),
_ => true, _ => true,
}) });
.collect();
if ast.body.len() < num_entries { if ast.body.len() < num_entries {
fs::write(entry.path(), serialize::serialize(&ast)).expect("failed to write file"); fs::write(entry.path(), serialize::serialize(&ast)).expect("failed to write file");

View file

@ -377,13 +377,13 @@ fn is_select_expr<'s, S: Slice<'s>>(expr: &Expression<S>) -> bool {
match expr { match expr {
Expression::Select { .. } => true, Expression::Select { .. } => true,
Expression::Inline(InlineExpression::Placeable { expression }) => { Expression::Inline(InlineExpression::Placeable { expression }) => {
is_select_expr(&*expression) is_select_expr(expression)
} }
Expression::Inline(_) => false, Expression::Inline(_) => false,
} }
} }
#[derive(Debug, Default, Copy, Clone, PartialEq)] #[derive(Debug, Default, Copy, Clone, PartialEq, Eq)]
pub struct Options { pub struct Options {
pub with_junk: bool, pub with_junk: bool,
} }

View file

@ -133,7 +133,7 @@ impl Backend {
let guard = self.col.lock().unwrap(); let guard = self.col.lock().unwrap();
guard guard
.is_some() .is_some()
.then(|| guard) .then_some(guard)
.ok_or(AnkiError::CollectionNotOpen) .ok_or(AnkiError::CollectionNotOpen)
} }
@ -141,7 +141,7 @@ impl Backend {
let guard = self.col.lock().unwrap(); let guard = self.col.lock().unwrap();
guard guard
.is_none() .is_none()
.then(|| guard) .then_some(guard)
.ok_or(AnkiError::CollectionAlreadyOpen) .ok_or(AnkiError::CollectionAlreadyOpen)
} }

View file

@ -17,7 +17,7 @@ use crate::{
text::html_to_text_line, 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")] #[strum(serialize_all = "camelCase")]
pub enum Column { pub enum Column {
#[strum(serialize = "")] #[strum(serialize = "")]

View file

@ -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)] #[repr(u8)]
pub enum CardType { pub enum CardType {
New = 0, New = 0,
@ -39,7 +39,7 @@ pub enum CardType {
Relearn = 3, 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)] #[repr(i8)]
pub enum CardQueue { pub enum CardQueue {
/// due is the order cards are shown in /// due is the order cards are shown in
@ -58,7 +58,7 @@ pub enum CardQueue {
UserBuried = -3, UserBuried = -3,
} }
#[derive(Debug, Clone, PartialEq)] #[derive(Debug, Clone, PartialEq, Eq)]
pub struct Card { pub struct Card {
pub(crate) id: CardId, pub(crate) id: CardId,
pub(crate) note_id: NoteId, pub(crate) note_id: NoteId,
@ -177,7 +177,7 @@ impl Card {
.unwrap_or(new_steps.len()) .unwrap_or(new_steps.len())
// (re)learning card must have at least 1 step remaining // (re)learning card must have at least 1 step remaining
.max(1) as u32; .max(1) as u32;
(remaining != new_remaining).then(|| new_remaining) (remaining != new_remaining).then_some(new_remaining)
} }
} }

View file

@ -75,7 +75,7 @@ struct TtsDirective<'a> {
options: HashMap<&'a str, &'a str>, options: HashMap<&'a str, &'a str>,
} }
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq, Eq)]
struct OtherDirective<'a> { struct OtherDirective<'a> {
name: &'a str, name: &'a str,
content: &'a str, content: &'a str,

View file

@ -119,7 +119,7 @@ fn datetime_from_file_name(file_name: &str) -> Option<DateTime<Local>> {
.and_then(|datetime| Local.from_local_datetime(&datetime).latest()) .and_then(|datetime| Local.from_local_datetime(&datetime).latest())
} }
#[derive(Debug, PartialEq, Clone)] #[derive(Debug, PartialEq, Eq, Clone)]
struct Backup { struct Backup {
path: PathBuf, path: PathBuf,
datetime: DateTime<Local>, datetime: DateTime<Local>,
@ -167,7 +167,7 @@ struct BackupFilter {
obsolete: Vec<Backup>, obsolete: Vec<Backup>,
} }
#[derive(Debug, Clone, Copy, PartialEq)] #[derive(Debug, Clone, Copy, PartialEq, Eq)]
enum BackupStage { enum BackupStage {
Daily, Daily,
Weekly, Weekly,

View file

@ -67,7 +67,7 @@ pub(crate) enum ConfigKey {
SchedulerVersion, SchedulerVersion,
} }
#[derive(PartialEq, Serialize_repr, Deserialize_repr, Clone, Copy, Debug)] #[derive(PartialEq, Eq, Serialize_repr, Deserialize_repr, Clone, Copy, Debug)]
#[repr(u8)] #[repr(u8)]
pub enum SchedulerVersion { pub enum SchedulerVersion {
V1 = 1, 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)] #[repr(u8)]
pub(crate) enum Weekday { pub(crate) enum Weekday {
Sunday = 0, Sunday = 0,

View file

@ -14,7 +14,7 @@ pub enum I32ConfigKey {
impl Collection { impl Collection {
pub fn get_config_i32(&self, key: I32ConfigKey) -> i32 { pub fn get_config_i32(&self, key: I32ConfigKey) -> i32 {
#[allow(clippy::match_single_binding)] #[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, _other => 0,
}) })
} }

View file

@ -19,7 +19,7 @@ use crate::{
timestamp::{TimestampMillis, TimestampSecs}, timestamp::{TimestampMillis, TimestampSecs},
}; };
#[derive(Debug, Default, PartialEq)] #[derive(Debug, Default, PartialEq, Eq)]
pub struct CheckDatabaseOutput { pub struct CheckDatabaseOutput {
card_properties_invalid: usize, card_properties_invalid: usize,
card_position_too_high: usize, card_position_too_high: usize,

View file

@ -80,7 +80,7 @@ pub struct NewConfSchema11 {
other: HashMap<String, Value>, other: HashMap<String, Value>,
} }
#[derive(Serialize_tuple, Debug, PartialEq, Clone)] #[derive(Serialize_tuple, Debug, PartialEq, Eq, Clone)]
pub struct NewCardIntervals { pub struct NewCardIntervals {
good: u16, good: u16,
easy: u16, easy: u16,
@ -120,7 +120,7 @@ where
.unwrap_or_default()) .unwrap_or_default())
} }
#[derive(Serialize_repr, Deserialize_repr, Debug, PartialEq, Clone)] #[derive(Serialize_repr, Deserialize_repr, Debug, PartialEq, Eq, Clone)]
#[repr(u8)] #[repr(u8)]
pub enum NewCardOrderSchema11 { pub enum NewCardOrderSchema11 {
Random = 0, Random = 0,
@ -154,7 +154,7 @@ pub struct RevConfSchema11 {
other: HashMap<String, Value>, other: HashMap<String, Value>,
} }
#[derive(Serialize_repr, Deserialize_repr, Debug, PartialEq, Clone)] #[derive(Serialize_repr, Deserialize_repr, Debug, PartialEq, Eq, Clone)]
#[repr(u8)] #[repr(u8)]
pub enum LeechAction { pub enum LeechAction {
Suspend = 0, Suspend = 0,

View file

@ -38,11 +38,11 @@ impl NormalDeck {
impl DayLimit { impl DayLimit {
pub fn limit(&self, today: u32) -> Option<u32> { 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(crate) struct RemainingLimits {
pub review: u32, pub review: u32,
pub new: u32, pub new: u32,

View file

@ -6,7 +6,7 @@ use itertools::Itertools;
use crate::{prelude::*, text::normalize_to_nfc}; use crate::{prelude::*, text::normalize_to_nfc};
#[derive(Debug, Clone, Default, PartialEq)] #[derive(Debug, Clone, Default, PartialEq, Eq)]
pub struct NativeDeckName(String); pub struct NativeDeckName(String);
impl NativeDeckName { impl NativeDeckName {
@ -242,7 +242,7 @@ mod test {
fn drag_drop() { fn drag_drop() {
// use custom separator to make the tests easier to read // use custom separator to make the tests easier to read
fn n(s: &str) -> NativeDeckName { fn n(s: &str) -> NativeDeckName {
NativeDeckName(s.replace(":", "\x1f")) NativeDeckName(s.replace(':', "\x1f"))
} }
#[allow(clippy::unnecessary_wraps)] #[allow(clippy::unnecessary_wraps)]

View file

@ -77,7 +77,7 @@ fn is_false(b: &bool) -> bool {
!b !b
} }
#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)] #[derive(Serialize, Deserialize, PartialEq, Eq, Debug, Clone)]
pub struct DeckCommonSchema11 { pub struct DeckCommonSchema11 {
#[serde(deserialize_with = "deserialize_number_from_string")] #[serde(deserialize_with = "deserialize_number_from_string")]
pub(crate) id: DeckId, pub(crate) id: DeckId,
@ -105,7 +105,7 @@ pub struct DeckCommonSchema11 {
other: HashMap<String, Value>, other: HashMap<String, Value>,
} }
#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)] #[derive(Serialize, Deserialize, PartialEq, Eq, Debug, Clone)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct NormalDeckSchema11 { pub struct NormalDeckSchema11 {
#[serde(flatten)] #[serde(flatten)]
@ -149,7 +149,7 @@ pub struct FilteredDeckSchema11 {
#[serde(default)] #[serde(default)]
preview_delay: u32, preview_delay: u32,
} }
#[derive(Serialize, Deserialize, Debug, PartialEq, Default, Clone)] #[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Default, Clone)]
pub struct DeckTodaySchema11 { pub struct DeckTodaySchema11 {
#[serde(rename = "lrnToday")] #[serde(rename = "lrnToday")]
pub(crate) lrn: TodayAmountSchema11, pub(crate) lrn: TodayAmountSchema11,
@ -161,7 +161,7 @@ pub struct DeckTodaySchema11 {
pub(crate) time: TodayAmountSchema11, 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>")] #[serde(from = "Vec<Value>")]
pub struct TodayAmountSchema11 { pub struct TodayAmountSchema11 {
day: i32, 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 { pub struct FilteredSearchTermSchema11 {
search: String, search: String,
#[serde(deserialize_with = "deserialize_number_from_string")] #[serde(deserialize_with = "deserialize_number_from_string")]

View file

@ -8,13 +8,13 @@ use rusqlite::{types::FromSqlError, Error};
use super::AnkiError; use super::AnkiError;
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq, Eq)]
pub struct DbError { pub struct DbError {
pub info: String, pub info: String,
pub kind: DbErrorKind, pub kind: DbErrorKind,
} }
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq, Eq)]
pub enum DbErrorKind { pub enum DbErrorKind {
FileTooNew, FileTooNew,
FileTooOld, FileTooOld,

View file

@ -5,7 +5,7 @@ use anki_i18n::I18n;
use super::AnkiError; use super::AnkiError;
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq, Eq)]
pub enum FilteredDeckError { pub enum FilteredDeckError {
MustBeLeafNode, MustBeLeafNode,
CanNotMoveCardsInto, CanNotMoveCardsInto,
@ -33,7 +33,7 @@ impl From<FilteredDeckError> for AnkiError {
} }
} }
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq, Eq)]
pub enum CustomStudyError { pub enum CustomStudyError {
NoMatchingCards, NoMatchingCards,
ExistingDeck, ExistingDeck,

View file

@ -18,7 +18,7 @@ use crate::{i18n::I18n, links::HelpPage};
pub type Result<T, E = AnkiError> = std::result::Result<T, E>; pub type Result<T, E = AnkiError> = std::result::Result<T, E>;
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq, Eq)]
pub enum AnkiError { pub enum AnkiError {
InvalidInput(String), InvalidInput(String),
TemplateError(String), TemplateError(String),
@ -138,7 +138,7 @@ impl AnkiError {
} }
} }
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq, Eq)]
pub enum TemplateError { pub enum TemplateError {
NoClosingBrackets(String), NoClosingBrackets(String),
ConditionalNotClosed(String), ConditionalNotClosed(String),
@ -195,14 +195,14 @@ impl From<csv::Error> for AnkiError {
} }
} }
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq, Eq)]
pub struct CardTypeError { pub struct CardTypeError {
pub notetype: String, pub notetype: String,
pub ordinal: usize, pub ordinal: usize,
pub details: CardTypeErrorDetails, pub details: CardTypeErrorDetails,
} }
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq, Eq)]
pub enum CardTypeErrorDetails { pub enum CardTypeErrorDetails {
TemplateError, TemplateError,
Duplicate(usize), Duplicate(usize),
@ -212,7 +212,7 @@ pub enum CardTypeErrorDetails {
ExtraneousCloze, ExtraneousCloze,
} }
#[derive(Debug, PartialEq, Clone)] #[derive(Debug, PartialEq, Eq, Clone)]
pub enum ImportError { pub enum ImportError {
Corrupt, Corrupt,
TooNew, TooNew,
@ -232,7 +232,7 @@ impl ImportError {
} }
} }
#[derive(Debug, PartialEq, Clone)] #[derive(Debug, PartialEq, Eq, Clone)]
pub struct FileIoError { pub struct FileIoError {
pub path: String, pub path: String,

View file

@ -6,13 +6,13 @@ use reqwest::StatusCode;
use super::AnkiError; use super::AnkiError;
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq, Eq)]
pub struct NetworkError { pub struct NetworkError {
pub info: String, pub info: String,
pub kind: NetworkErrorKind, pub kind: NetworkErrorKind,
} }
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq, Eq)]
pub enum NetworkErrorKind { pub enum NetworkErrorKind {
Offline, Offline,
Timeout, Timeout,
@ -20,13 +20,13 @@ pub enum NetworkErrorKind {
Other, Other,
} }
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq, Eq)]
pub struct SyncError { pub struct SyncError {
pub info: String, pub info: String,
pub kind: SyncErrorKind, pub kind: SyncErrorKind,
} }
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq, Eq)]
pub enum SyncErrorKind { pub enum SyncErrorKind {
Conflict, Conflict,
ServerError, ServerError,

View file

@ -8,13 +8,13 @@ use nom::error::{ErrorKind as NomErrorKind, ParseError as NomParseError};
use super::AnkiError; use super::AnkiError;
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq, Eq)]
pub enum ParseError<'a> { pub enum ParseError<'a> {
Anki(&'a str, SearchErrorKind), Anki(&'a str, SearchErrorKind),
Nom(&'a str, NomErrorKind), Nom(&'a str, NomErrorKind),
} }
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq, Eq)]
pub enum SearchErrorKind { pub enum SearchErrorKind {
MisplacedAnd, MisplacedAnd,
MisplacedOr, MisplacedOr,

View file

@ -124,14 +124,18 @@ impl ExchangeData {
fn check_ids(&self) -> Result<()> { fn check_ids(&self) -> Result<()> {
let now = TimestampMillis::now().0; let now = TimestampMillis::now().0;
self.cards if self
.cards
.iter() .iter()
.map(|card| card.id.0) .map(|card| card.id.0)
.chain(self.notes.iter().map(|note| note.id.0)) .chain(self.notes.iter().map(|note| note.id.0))
.chain(self.revlog.iter().map(|entry| entry.id.0)) .chain(self.revlog.iter().map(|entry| entry.id.0))
.any(|timestamp| timestamp > now) .any(|timestamp| timestamp > now)
.then(|| Err(AnkiError::InvalidId)) {
.unwrap_or(Ok(())) Err(AnkiError::InvalidId)
} else {
Ok(())
}
} }
} }

View file

@ -17,7 +17,7 @@ use crate::{
}, },
}; };
#[derive(Debug, Clone, Copy, PartialEq)] #[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ImportProgress { pub enum ImportProgress {
File, File,
Extracting, Extracting,
@ -27,7 +27,7 @@ pub enum ImportProgress {
Notes(usize), Notes(usize),
} }
#[derive(Debug, Clone, Copy, PartialEq)] #[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ExportProgress { pub enum ExportProgress {
File, File,
Gathering, Gathering,

View file

@ -263,7 +263,7 @@ impl<'n> NoteContext<'n> {
Ok(()) 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| { replace_media_refs(field, |name| {
if let Ok(normalized) = safe_normalized_file_name(name) { if let Ok(normalized) = safe_normalized_file_name(name) {
if let Some(entry) = self.media_map.use_entry(&normalized) { if let Some(entry) = self.media_map.use_entry(&normalized) {

View file

@ -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)) .pragma_query_value(None, "integrity_check", |row| row.get::<_, String>(0))
.ok() .ok()
}) })
.and_then(|s| (s == "ok").then(|| ())) .and_then(|s| (s == "ok").then_some(()))
.ok_or(AnkiError::ImportError(ImportError::Corrupt)) .ok_or(AnkiError::ImportError(ImportError::Corrupt))
} }

View file

@ -211,7 +211,7 @@ impl NoteContext {
} }
fn guid_column(&self) -> Option<usize> { fn guid_column(&self) -> Option<usize> {
self.with_guid.then(|| 1) self.with_guid.then_some(1)
} }
fn notetype_column(&self) -> Option<usize> { fn notetype_column(&self) -> Option<usize> {

View file

@ -61,7 +61,7 @@ impl CsvMetadata {
CsvNotetype::GlobalNotetype(global) => global CsvNotetype::GlobalNotetype(global) => global
.field_columns .field_columns
.iter() .iter()
.map(|&i| (i > 0).then(|| i as usize)) .map(|&i| (i > 0).then_some(i as usize))
.collect(), .collect(),
CsvNotetype::NotetypeColumn(_) => { CsvNotetype::NotetypeColumn(_) => {
let meta_columns = self.meta_columns(); let meta_columns = self.meta_columns();
@ -124,8 +124,8 @@ struct ColumnContext {
impl ColumnContext { impl ColumnContext {
fn new(metadata: &CsvMetadata) -> Result<Self> { fn new(metadata: &CsvMetadata) -> Result<Self> {
Ok(Self { Ok(Self {
tags_column: (metadata.tags_column > 0).then(|| metadata.tags_column as usize), tags_column: (metadata.tags_column > 0).then_some(metadata.tags_column as usize),
guid_column: (metadata.guid_column > 0).then(|| metadata.guid_column as usize), guid_column: (metadata.guid_column > 0).then_some(metadata.guid_column as usize),
deck_column: metadata.deck()?.column(), deck_column: metadata.deck()?.column(),
notetype_column: metadata.notetype()?.column(), notetype_column: metadata.notetype()?.column(),
field_source_columns: metadata.field_source_columns()?, field_source_columns: metadata.field_source_columns()?,

View file

@ -404,12 +404,9 @@ fn maybe_set_tags_column(metadata: &mut CsvMetadata, meta_columns: &HashSet<usiz
fn delimiter_from_value(value: &str) -> Option<Delimiter> { fn delimiter_from_value(value: &str) -> Option<Delimiter> {
let normed = value.to_ascii_lowercase(); let normed = value.to_ascii_lowercase();
for delimiter in Delimiter::iter() { Delimiter::iter().find(|&delimiter| {
if normed.trim() == delimiter.name() || normed.as_bytes() == [delimiter.byte()] { normed.trim() == delimiter.name() || normed.as_bytes() == [delimiter.byte()]
return Some(delimiter); })
}
}
None
} }
fn delimiter_from_reader(mut reader: impl Read) -> Result<Delimiter> { fn delimiter_from_reader(mut reader: impl Read) -> Result<Delimiter> {

View file

@ -22,7 +22,7 @@ pub struct ForeignData {
updated_tags: Vec<String>, updated_tags: Vec<String>,
} }
#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, Eq, Default, Serialize, Deserialize)]
#[serde(default)] #[serde(default)]
pub struct ForeignNote { pub struct ForeignNote {
guid: String, guid: String,
@ -43,7 +43,7 @@ pub struct ForeignCard {
pub lapses: u32, pub lapses: u32,
} }
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct ForeignNotetype { pub struct ForeignNotetype {
name: String, name: String,
fields: Vec<String>, fields: Vec<String>,
@ -52,7 +52,7 @@ pub struct ForeignNotetype {
is_cloze: bool, is_cloze: bool,
} }
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct ForeignTemplate { pub struct ForeignTemplate {
name: String, name: String,
qfmt: String, qfmt: String,

View file

@ -33,7 +33,7 @@ pub(crate) fn contains_latex(text: &str) -> bool {
LATEX.is_match(text) LATEX.is_match(text)
} }
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq, Eq)]
pub struct ExtractedLatex { pub struct ExtractedLatex {
pub fname: String, pub fname: String,
pub latex: String, pub latex: String,

View file

@ -27,7 +27,7 @@ use crate::{
text::{extract_media_refs, normalize_to_nfc, MediaRef, REMOTE_FILENAME}, text::{extract_media_refs, normalize_to_nfc, MediaRef, REMOTE_FILENAME},
}; };
#[derive(Debug, PartialEq, Clone)] #[derive(Debug, PartialEq, Eq, Clone)]
pub struct MediaCheckOutput { pub struct MediaCheckOutput {
pub unused: Vec<String>, pub unused: Vec<String>,
pub missing: Vec<String>, pub missing: Vec<String>,
@ -38,7 +38,7 @@ pub struct MediaCheckOutput {
pub trash_bytes: u64, pub trash_bytes: u64,
} }
#[derive(Debug, PartialEq, Default)] #[derive(Debug, PartialEq, Eq, Default)]
struct MediaFolderCheck { struct MediaFolderCheck {
files: Vec<String>, files: Vec<String>,
renamed: HashMap<String, String>, renamed: HashMap<String, String>,

View file

@ -43,7 +43,7 @@ fn initial_db_setup(db: &mut Connection) -> Result<()> {
Ok(()) Ok(())
} }
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq, Eq)]
pub struct MediaEntry { pub struct MediaEntry {
pub fname: String, pub fname: String,
/// If None, file has been deleted /// If None, file has been deleted
@ -54,7 +54,7 @@ pub struct MediaEntry {
pub sync_required: bool, pub sync_required: bool,
} }
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq, Eq)]
pub struct MediaDatabaseMetadata { pub struct MediaDatabaseMetadata {
/// The syncing code no longer uses this; files are scanned for /// The syncing code no longer uses this; files are scanned for
/// indiscriminately. After this has been in production for a while /// indiscriminately. After this has been in production for a while

View file

@ -79,7 +79,7 @@ enum LocalState {
InDbAndPending, InDbAndPending,
} }
#[derive(PartialEq, Debug)] #[derive(PartialEq, Eq, Debug)]
enum RequiredChange { enum RequiredChange {
// none also covers the case where we'll later upload // none also covers the case where we'll later upload
None, None,

View file

@ -37,7 +37,7 @@ pub(crate) struct TransformNoteOutput {
pub update_tags: bool, pub update_tags: bool,
} }
#[derive(Debug, PartialEq, Clone)] #[derive(Debug, PartialEq, Eq, Clone)]
pub struct Note { pub struct Note {
pub id: NoteId, pub id: NoteId,
pub guid: String, pub guid: String,
@ -108,7 +108,7 @@ impl Collection {
/// Information required for updating tags while leaving note content alone. /// Information required for updating tags while leaving note content alone.
/// Tags are stored in their DB form, separated by spaces. /// Tags are stored in their DB form, separated by spaces.
#[derive(Debug, PartialEq, Clone)] #[derive(Debug, PartialEq, Eq, Clone)]
pub(crate) struct NoteTags { pub(crate) struct NoteTags {
pub id: NoteId, pub id: NoteId,
pub mtime: TimestampSecs, pub mtime: TimestampSecs,
@ -747,7 +747,7 @@ mod test {
col.storage.db_scalar::<u32>("select count() from graves")?, col.storage.db_scalar::<u32>("select count() from graves")?,
0 0
); );
assert!(!col.get_next_card()?.is_some()); assert!(col.get_next_card()?.is_none());
Ok(()) Ok(())
}; };
@ -786,7 +786,7 @@ mod test {
col.storage.db_scalar::<u32>("select count() from graves")?, col.storage.db_scalar::<u32>("select count() from graves")?,
3 3
); );
assert!(!col.get_next_card()?.is_some()); assert!(col.get_next_card()?.is_none());
Ok(()) Ok(())
}; };

View file

@ -16,7 +16,7 @@ use crate::{
}; };
/// Info about an existing card required when generating new cards /// Info about an existing card required when generating new cards
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq, Eq)]
pub(crate) struct AlreadyGeneratedCardInfo { pub(crate) struct AlreadyGeneratedCardInfo {
pub id: CardId, pub id: CardId,
pub nid: NoteId, pub nid: NoteId,
@ -178,7 +178,7 @@ pub(super) fn group_generated_cards_by_note(
out out
} }
#[derive(Debug, PartialEq, Default)] #[derive(Debug, PartialEq, Eq, Default)]
pub(crate) struct ExtractedCardInfo { pub(crate) struct ExtractedCardInfo {
// if set, the due position new cards should be given // if set, the due position new cards should be given
pub due: Option<u32>, pub due: Option<u32>,

View file

@ -14,7 +14,7 @@ use crate::{
text::{HTML_MEDIA_TAGS, SOUND_TAG}, text::{HTML_MEDIA_TAGS, SOUND_TAG},
}; };
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq, Eq)]
struct Template<'a> { struct Template<'a> {
notetype: &'a str, notetype: &'a str,
card_type: &'a str, card_type: &'a str,

View file

@ -33,7 +33,7 @@ pub struct NotetypeChangeInfo {
pub new_template_names: Vec<String>, pub new_template_names: Vec<String>,
} }
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq, Eq)]
pub struct TemplateMap { pub struct TemplateMap {
pub removed: Vec<usize>, pub removed: Vec<usize>,
pub remapped: HashMap<usize, usize>, pub remapped: HashMap<usize, usize>,

View file

@ -20,7 +20,7 @@ use crate::{
types::Usn, types::Usn,
}; };
#[derive(Serialize_repr, Deserialize_repr, PartialEq, Debug, Clone)] #[derive(Serialize_repr, Deserialize_repr, PartialEq, Eq, Debug, Clone)]
#[repr(u8)] #[repr(u8)]
pub enum NotetypeKind { pub enum NotetypeKind {
Standard = 0, Standard = 0,

View file

@ -20,7 +20,7 @@ fn ords_changed(ords: &[Option<u32>], previous_len: usize) -> bool {
.any(|(idx, &ord)| ord != Some(idx as u32)) .any(|(idx, &ord)| ord != Some(idx as u32))
} }
#[derive(Default, PartialEq, Debug)] #[derive(Default, PartialEq, Eq, Debug)]
struct TemplateOrdChanges { struct TemplateOrdChanges {
added: Vec<u32>, added: Vec<u32>,
removed: Vec<u16>, removed: Vec<u16>,

View file

@ -3,7 +3,7 @@
use crate::prelude::*; use crate::prelude::*;
#[derive(Debug, Clone, PartialEq)] #[derive(Debug, Clone, PartialEq, Eq)]
pub enum Op { pub enum Op {
Custom(String), Custom(String),
AddDeck, AddDeck,
@ -95,7 +95,7 @@ impl Op {
} }
} }
#[derive(Debug, PartialEq, Default, Clone, Copy)] #[derive(Debug, PartialEq, Eq, Default, Clone, Copy)]
pub struct StateChanges { pub struct StateChanges {
pub card: bool, pub card: bool,
pub note: bool, pub note: bool,
@ -107,13 +107,13 @@ pub struct StateChanges {
pub mtime: bool, pub mtime: bool,
} }
#[derive(Debug, PartialEq, Clone)] #[derive(Debug, PartialEq, Eq, Clone)]
pub struct OpChanges { pub struct OpChanges {
pub op: Op, pub op: Op,
pub changes: StateChanges, pub changes: StateChanges,
} }
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq, Eq)]
pub struct OpOutput<T> { pub struct OpOutput<T> {
pub output: T, pub output: T,
pub changes: OpChanges, pub changes: OpChanges,

View file

@ -4,6 +4,7 @@
macro_rules! protobuf { macro_rules! protobuf {
($ident:ident) => { ($ident:ident) => {
pub mod $ident { pub mod $ident {
#![allow(clippy::derive_partial_eq_without_eq)]
include!(concat!( include!(concat!(
env!("OUT_DIR"), env!("OUT_DIR"),
concat!("/anki.", stringify!($ident), ".rs") concat!("/anki.", stringify!($ident), ".rs")

View file

@ -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 struct RevlogEntry {
pub id: RevlogId, pub id: RevlogId,
pub cid: CardId, pub cid: CardId,
@ -57,7 +57,7 @@ pub struct RevlogEntry {
pub review_kind: RevlogReviewKind, 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)] #[repr(u8)]
pub enum RevlogReviewKind { pub enum RevlogReviewKind {
Learning = 0, Learning = 0,

View file

@ -19,9 +19,11 @@ use crate::{
impl Card { impl Card {
pub(crate) fn original_or_current_due(&self) -> i32 { pub(crate) fn original_or_current_due(&self) -> i32 {
self.is_filtered() if self.is_filtered() {
.then(|| self.original_due) self.original_due
.unwrap_or(self.due) } else {
self.due
}
} }
pub(crate) fn last_position(&self) -> Option<u32> { pub(crate) fn last_position(&self) -> Option<u32> {
@ -77,7 +79,7 @@ pub(crate) struct NewCardSorter {
position: HashMap<NoteId, u32>, position: HashMap<NoteId, u32>,
} }
#[derive(PartialEq)] #[derive(PartialEq, Eq)]
pub enum NewCardDueOrder { pub enum NewCardDueOrder {
NoteId, NoteId,
Random, Random,

View file

@ -4,7 +4,7 @@
use super::{LearningQueueEntry, MainQueueEntry, MainQueueEntryKind}; use super::{LearningQueueEntry, MainQueueEntry, MainQueueEntryKind};
use crate::{card::CardQueue, prelude::*}; use crate::{card::CardQueue, prelude::*};
#[derive(Clone, Copy, Debug, PartialEq)] #[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub(crate) enum QueueEntry { pub(crate) enum QueueEntry {
IntradayLearning(LearningQueueEntry), IntradayLearning(LearningQueueEntry),
Main(MainQueueEntry), Main(MainQueueEntry),
@ -37,7 +37,7 @@ impl QueueEntry {
} }
} }
#[derive(Clone, Copy, Debug, PartialEq)] #[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum QueueEntryKind { pub enum QueueEntryKind {
New, New,
Learning, Learning,

View file

@ -4,14 +4,14 @@
use super::CardQueues; use super::CardQueues;
use crate::prelude::*; use crate::prelude::*;
#[derive(Clone, Copy, Debug, PartialEq)] #[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub(crate) struct MainQueueEntry { pub(crate) struct MainQueueEntry {
pub id: CardId, pub id: CardId,
pub mtime: TimestampSecs, pub mtime: TimestampSecs,
pub kind: MainQueueEntryKind, pub kind: MainQueueEntryKind,
} }
#[derive(Clone, Copy, Debug, PartialEq)] #[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub(crate) enum MainQueueEntryKind { pub(crate) enum MainQueueEntryKind {
New, New,
Review, Review,

View file

@ -146,7 +146,7 @@ mod test {
let deck = col.get_deck(DeckId(1))?.unwrap(); let deck = col.get_deck(DeckId(1))?.unwrap();
assert_eq!(deck.common.review_studied, 1); assert_eq!(deck.common.review_studied, 1);
assert!(!col.get_next_card()?.is_some()); assert!(col.get_next_card()?.is_none());
Ok(()) Ok(())
}; };

View file

@ -55,7 +55,7 @@ impl Card {
} }
} }
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq, Eq)]
pub struct DueDateSpecifier { pub struct DueDateSpecifier {
min: u32, min: u32,
max: u32, max: u32,

View file

@ -1,7 +1,7 @@
// Copyright: Ankitects Pty Ltd and contributors // Copyright: Ankitects Pty Ltd and contributors
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html // 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 { pub(crate) enum IntervalKind {
InSecs(u32), InSecs(u32),
InDays(u32), InDays(u32),

View file

@ -4,7 +4,7 @@
use super::{interval_kind::IntervalKind, CardState, ReviewState, SchedulingStates, StateContext}; use super::{interval_kind::IntervalKind, CardState, ReviewState, SchedulingStates, StateContext};
use crate::revlog::RevlogReviewKind; use crate::revlog::RevlogReviewKind;
#[derive(Debug, Clone, Copy, PartialEq)] #[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct LearnState { pub struct LearnState {
pub remaining_steps: u32, pub remaining_steps: u32,
pub scheduled_secs: u32, pub scheduled_secs: u32,

View file

@ -4,7 +4,7 @@
use super::interval_kind::IntervalKind; use super::interval_kind::IntervalKind;
use crate::revlog::RevlogReviewKind; use crate::revlog::RevlogReviewKind;
#[derive(Debug, Clone, Copy, PartialEq, Default)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub struct NewState { pub struct NewState {
pub position: u32, pub position: u32,
} }

View file

@ -4,7 +4,7 @@
use super::{IntervalKind, SchedulingStates, StateContext}; use super::{IntervalKind, SchedulingStates, StateContext};
use crate::revlog::RevlogReviewKind; use crate::revlog::RevlogReviewKind;
#[derive(Debug, Clone, Copy, PartialEq)] #[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct PreviewState { pub struct PreviewState {
pub scheduled_secs: u32, pub scheduled_secs: u32,
pub finished: bool, pub finished: bool,

View file

@ -5,7 +5,7 @@ use chrono::{Date, Duration, FixedOffset, Local, TimeZone, Timelike};
use crate::prelude::*; use crate::prelude::*;
#[derive(Debug, PartialEq, Clone, Copy)] #[derive(Debug, PartialEq, Eq, Clone, Copy)]
pub struct SchedTimingToday { pub struct SchedTimingToday {
pub now: TimestampSecs, pub now: TimestampSecs,
/// The number of days that have passed since the collection was created. /// The number of days that have passed since the collection was created.

View file

@ -25,13 +25,13 @@ use crate::{
prelude::AnkiError, prelude::AnkiError,
}; };
#[derive(Debug, PartialEq, Clone, Copy)] #[derive(Debug, PartialEq, Eq, Clone, Copy)]
pub enum ReturnItemType { pub enum ReturnItemType {
Cards, Cards,
Notes, Notes,
} }
#[derive(Debug, PartialEq, Clone)] #[derive(Debug, PartialEq, Eq, Clone)]
pub enum SortMode { pub enum SortMode {
NoOrder, NoOrder,
Builtin { column: Column, reverse: bool }, Builtin { column: Column, reverse: bool },

View file

@ -97,7 +97,7 @@ pub enum PropertyKind {
Rated(i32, RatingKind), Rated(i32, RatingKind),
} }
#[derive(Debug, PartialEq, Clone)] #[derive(Debug, PartialEq, Eq, Clone)]
pub enum StateKind { pub enum StateKind {
New, New,
Review, Review,
@ -109,13 +109,13 @@ pub enum StateKind {
Suspended, Suspended,
} }
#[derive(Debug, PartialEq, Clone)] #[derive(Debug, PartialEq, Eq, Clone)]
pub enum TemplateKind { pub enum TemplateKind {
Ordinal(u16), Ordinal(u16),
Name(String), Name(String),
} }
#[derive(Debug, PartialEq, Clone)] #[derive(Debug, PartialEq, Eq, Clone)]
pub enum RatingKind { pub enum RatingKind {
AnswerButton(u8), AnswerButton(u8),
AnyAnswerButton, AnyAnswerButton,

View file

@ -612,7 +612,7 @@ impl SqlWriter<'_> {
} }
} }
#[derive(Debug, PartialEq, Clone, Copy)] #[derive(Debug, PartialEq, Eq, Clone, Copy)]
pub enum RequiredTable { pub enum RequiredTable {
Notes, Notes,
Cards, Cards,

View file

@ -73,7 +73,7 @@ mod test {
use super::*; use super::*;
#[derive(Deserialize, Debug, PartialEq)] #[derive(Deserialize, Debug, PartialEq, Eq)]
struct MaybeInvalid { struct MaybeInvalid {
#[serde(deserialize_with = "default_on_invalid", default)] #[serde(deserialize_with = "default_on_invalid", default)]
field: Option<usize>, field: Option<usize>,

View file

@ -34,7 +34,7 @@ mod test {
// temporary test of fluent term handling // temporary test of fluent term handling
let tr = I18n::template_only(); let tr = I18n::template_only();
assert_eq!( 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)" "Studied 3 cards in 13 seconds today (4.33s/card)"
); );
} }

View file

@ -13,7 +13,7 @@ use serde_json::Value;
use crate::{prelude::*, serde::default_on_invalid}; use crate::{prelude::*, serde::default_on_invalid};
/// Helper for serdeing the card data column. /// Helper for serdeing the card data column.
#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, Eq, Default, Serialize, Deserialize)]
#[serde(default)] #[serde(default)]
pub(crate) struct CardData { pub(crate) struct CardData {
#[serde( #[serde(

View file

@ -21,7 +21,7 @@ use std::fmt::Write;
pub(crate) use sqlite::SqliteStorage; pub(crate) use sqlite::SqliteStorage;
pub(crate) use sync::open_and_check_sqlite_file; pub(crate) use sync::open_and_check_sqlite_file;
#[derive(Debug, Clone, Copy, PartialEq)] #[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub(crate) enum SchemaVersion { pub(crate) enum SchemaVersion {
V11, V11,
V18, V18,

View file

@ -46,7 +46,7 @@ pub struct NormalSyncProgress {
pub remote_remove: usize, pub remote_remove: usize,
} }
#[derive(Debug, Clone, Copy, PartialEq)] #[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum SyncStage { pub enum SyncStage {
Connecting, Connecting,
Syncing, Syncing,
@ -176,14 +176,14 @@ pub struct SanityCheckResponse {
pub server: Option<SanityCheckCounts>, pub server: Option<SanityCheckCounts>,
} }
#[derive(Serialize, Deserialize, Debug, PartialEq)] #[derive(Serialize, Deserialize, Debug, PartialEq, Eq)]
#[serde(rename_all = "lowercase")] #[serde(rename_all = "lowercase")]
pub enum SanityCheckStatus { pub enum SanityCheckStatus {
Ok, Ok,
Bad, Bad,
} }
#[derive(Serialize_tuple, Deserialize, Debug, PartialEq)] #[derive(Serialize_tuple, Deserialize, Debug, PartialEq, Eq)]
pub struct SanityCheckCounts { pub struct SanityCheckCounts {
pub counts: SanityCheckDueCounts, pub counts: SanityCheckDueCounts,
pub cards: u32, pub cards: u32,
@ -196,7 +196,7 @@ pub struct SanityCheckCounts {
pub deck_config: u32, pub deck_config: u32,
} }
#[derive(Serialize_tuple, Deserialize, Debug, Default, PartialEq)] #[derive(Serialize_tuple, Deserialize, Debug, Default, PartialEq, Eq)]
pub struct SanityCheckDueCounts { pub struct SanityCheckDueCounts {
pub new: u32, pub new: u32,
pub learn: u32, pub learn: u32,
@ -209,7 +209,7 @@ pub struct FullSyncProgress {
pub total_bytes: usize, pub total_bytes: usize,
} }
#[derive(PartialEq, Debug, Clone, Copy)] #[derive(PartialEq, Eq, Debug, Clone, Copy)]
pub enum SyncActionRequired { pub enum SyncActionRequired {
NoChanges, NoChanges,
FullSyncRequired { upload_ok: bool, download_ok: bool }, FullSyncRequired { upload_ok: bool, download_ok: bool },

View file

@ -17,7 +17,7 @@ use unicase::UniCase;
use crate::prelude::*; use crate::prelude::*;
#[derive(Debug, Clone, PartialEq)] #[derive(Debug, Clone, PartialEq, Eq)]
pub struct Tag { pub struct Tag {
pub name: String, pub name: String,
pub usn: Usn, pub usn: Usn,

View file

@ -175,7 +175,7 @@ fn legacy_tokens(mut data: &str) -> impl Iterator<Item = TemplateResult<Token>>
// Parsing // Parsing
//---------------------------------------- //----------------------------------------
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq, Eq)]
enum ParsedNode { enum ParsedNode {
Text(String), Text(String),
Replacement { Replacement {
@ -371,7 +371,7 @@ fn template_is_empty(
// Rendering // Rendering
//---------------------------------------- //----------------------------------------
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq, Eq)]
pub enum RenderedNode { pub enum RenderedNode {
Text { Text {
text: String, text: String,
@ -632,7 +632,7 @@ fn cloze_is_empty(field_map: &HashMap<&str, Cow<str>>, card_ord: u16) -> bool {
// Field requirements // Field requirements
//---------------------------------------- //----------------------------------------
#[derive(Debug, Clone, PartialEq)] #[derive(Debug, Clone, PartialEq, Eq)]
pub enum FieldRequirements { pub enum FieldRequirements {
Any(HashSet<u16>), Any(HashSet<u16>),
All(HashSet<u16>), All(HashSet<u16>),

View file

@ -115,20 +115,20 @@ fn prepare_provided(provided: &str) -> String {
normalize_to_nfc(provided).into() normalize_to_nfc(provided).into()
} }
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq, Eq)]
enum DiffTokenKind { enum DiffTokenKind {
Good, Good,
Bad, Bad,
Missing, Missing,
} }
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq, Eq)]
struct DiffToken<'a> { struct DiffToken<'a> {
kind: DiffTokenKind, kind: DiffTokenKind,
text: Cow<'a, str>, text: Cow<'a, str>,
} }
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq, Eq)]
struct DiffOutput<'a> { struct DiffOutput<'a> {
provided: Vec<DiffToken<'a>>, provided: Vec<DiffToken<'a>>,
expected: Vec<DiffToken<'a>>, expected: Vec<DiffToken<'a>>,

View file

@ -30,7 +30,7 @@ impl UndoableOp {
} }
} }
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq, Eq)]
enum UndoMode { enum UndoMode {
NormalOp, NormalOp,
Undoing, Undoing,