Added sorting for cards
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
use deunicode::deunicode;
|
||||
use rusqlite;
|
||||
use std::cmp::Ordering;
|
||||
use std::fmt;
|
||||
use std::fs;
|
||||
use std::path::PathBuf;
|
||||
@@ -75,6 +76,26 @@ impl fmt::Display for DbCard {
|
||||
}
|
||||
}
|
||||
|
||||
impl Ord for DbCard {
|
||||
fn cmp(&self, other: &Self) -> Ordering {
|
||||
self.name.cmp(&other.name)
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialOrd for DbCard {
|
||||
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
|
||||
Some(self.cmp(other))
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialEq for DbCard {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
self.name == other.name
|
||||
}
|
||||
}
|
||||
|
||||
impl Eq for DbCard {}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct DbCard {
|
||||
pub name: String,
|
||||
|
||||
@@ -92,7 +92,7 @@ fn main() -> MtgCardExit {
|
||||
return res;
|
||||
}
|
||||
|
||||
let matching_cards = find_matching_cards_scryfall_style(&args.search_text);
|
||||
let mut matching_cards = find_matching_cards_scryfall_style(&args.search_text);
|
||||
dbg!(&args.search_text);
|
||||
dbg!(&matching_cards);
|
||||
|
||||
@@ -119,6 +119,7 @@ fn main() -> MtgCardExit {
|
||||
// TODO update this to be more meaningful
|
||||
return MtgCardExit::ExactCardFound;
|
||||
} else {
|
||||
matching_cards.sort();
|
||||
for card in matching_cards {
|
||||
println!(
|
||||
"{}",
|
||||
|
||||
Reference in New Issue
Block a user