mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
custom ord/partialeq is not required; fix clippy lint
This commit is contained in:
parent
a390a77815
commit
d54acba81f
1 changed files with 2 additions and 23 deletions
|
@ -11,37 +11,16 @@ use crate::{
|
||||||
};
|
};
|
||||||
|
|
||||||
use regex::{NoExpand, Regex, Replacer};
|
use regex::{NoExpand, Regex, Replacer};
|
||||||
use std::cmp::Ordering;
|
|
||||||
use std::{borrow::Cow, collections::HashSet, iter::Peekable};
|
use std::{borrow::Cow, collections::HashSet, iter::Peekable};
|
||||||
use unicase::UniCase;
|
use unicase::UniCase;
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
pub struct Tag {
|
pub struct Tag {
|
||||||
pub name: String,
|
pub name: String,
|
||||||
pub usn: Usn,
|
pub usn: Usn,
|
||||||
pub collapsed: bool,
|
pub collapsed: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Ord for Tag {
|
|
||||||
fn cmp(&self, other: &Self) -> Ordering {
|
|
||||||
UniCase::new(&self.name).cmp(&UniCase::new(&other.name))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl PartialOrd for Tag {
|
|
||||||
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
|
|
||||||
Some(self.cmp(other))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl PartialEq for Tag {
|
|
||||||
fn eq(&self, other: &Self) -> bool {
|
|
||||||
self.cmp(other) == Ordering::Equal
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Eq for Tag {}
|
|
||||||
|
|
||||||
impl From<Tag> for TagProto {
|
impl From<Tag> for TagProto {
|
||||||
fn from(t: Tag) -> Self {
|
fn from(t: Tag) -> Self {
|
||||||
TagProto {
|
TagProto {
|
||||||
|
@ -132,7 +111,7 @@ fn add_self_and_missing_parents<'a, 'b>(
|
||||||
) {
|
) {
|
||||||
if let Some(parent) = immediate_parent_name(tag_name) {
|
if let Some(parent) = immediate_parent_name(tag_name) {
|
||||||
if !all.contains(&parent) {
|
if !all.contains(&parent) {
|
||||||
missing.push(parent.clone());
|
missing.push(parent);
|
||||||
add_self_and_missing_parents(all, missing, parent);
|
add_self_and_missing_parents(all, missing, parent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue