Skip to main content

CardComparatorGen

Struct CardComparatorGen 

Source
pub struct CardComparatorGen<F: FigureTrait, S: SuitTrait, CF: Comparator<F> + Default, CS: Comparator<S> + Default> {
    pub suit_comparator: CS,
    pub figure_comparator: CF,
    pub _phantom: PhantomData<(F, S)>,
}

Fields§

§suit_comparator: CS§figure_comparator: CF§_phantom: PhantomData<(F, S)>

Implementations§

Source§

impl<F: FigureTrait + Copy, S: SuitTrait + Copy, CS: Comparator<S> + Default, CF: Comparator<F> + Default> CardComparatorGen<F, S, CF, CS>

Source

pub fn cmp_suit_figure( &self, l: &Card2SGen<F, S>, r: &Card2SGen<F, S>, ) -> Ordering

use karty::cards::{STANDARD_DECK};
use karty::figures::FigureComparator;
use karty::suits::ComparatorDCHS;
use karty::cards::*;

let mut deck = Vec::from(STANDARD_DECK);
let bridge_comparator = CARD_COMPARATOR_BRIDGE;
assert_eq!(deck[51], ACE_SPADES);
assert_eq!(deck[50], ACE_HEARTS);
deck.sort_by(|l, r | bridge_comparator.cmp_suit_figure(l, r));
assert_eq!(deck[51], ACE_SPADES);
assert_eq!(deck[50], KING_SPADES);
Source

pub fn cmp_figure_suit( &self, l: &Card2SGen<F, S>, r: &Card2SGen<F, S>, ) -> Ordering

use karty::cards::{STANDARD_DECK};
use karty::figures::FigureComparator;
use karty::suits::ComparatorDCHS;
use karty::cards::*;

let mut deck = Vec::from(STANDARD_DECK);
let bridge_comparator = CARD_COMPARATOR_VISUAL;
assert_eq!(deck[51], ACE_SPADES);
assert_eq!(deck[50], ACE_HEARTS);
assert_eq!(deck[49], ACE_DIAMONDS);
assert_eq!(deck[48], ACE_CLUBS);
deck.sort_by(|l, r | bridge_comparator.cmp_figure_suit(l, r));
assert_eq!(deck[51], ACE_SPADES);
assert_eq!(deck[50], ACE_HEARTS);
assert_eq!(deck[49], ACE_CLUBS);
assert_eq!(deck[48], ACE_DIAMONDS);

Trait Implementations§

Source§

impl<F: FigureTrait, S: SuitTrait, CS: Comparator<S> + Default, CF: Comparator<F> + Default> Default for CardComparatorGen<F, S, CF, CS>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<F, S, CF, CS> Freeze for CardComparatorGen<F, S, CF, CS>

§

impl<F, S, CF, CS> RefUnwindSafe for CardComparatorGen<F, S, CF, CS>

§

impl<F, S, CF, CS> Send for CardComparatorGen<F, S, CF, CS>
where CS: Send, CF: Send, PhantomData<(F, S)>: Send,

§

impl<F, S, CF, CS> Sync for CardComparatorGen<F, S, CF, CS>
where CS: Sync, CF: Sync, PhantomData<(F, S)>: Sync,

§

impl<F, S, CF, CS> Unpin for CardComparatorGen<F, S, CF, CS>
where CS: Unpin, CF: Unpin, PhantomData<(F, S)>: Unpin,

§

impl<F, S, CF, CS> UnsafeUnpin for CardComparatorGen<F, S, CF, CS>

§

impl<F, S, CF, CS> UnwindSafe for CardComparatorGen<F, S, CF, CS>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V