pub struct Match<'a> {
    pub result: f32,
    /* private fields */
}
Expand description

A match between two opponents.

Fields§

§result: f32

1: Player one wins. 0: Player two wins.

Implementations§

source§

impl Match<'_>

source

pub fn new<'a>( player_one: &'a mut EloPlayer, player_two: &'a mut EloPlayer, result: f32 ) -> Match<'a>

Creates a new match between two players.

Arguments
  • player_one: &'a mut EloPlayer - The first player.
  • player_two: &'a mut EloPlayer - The second player.
  • result: f32 - The result. 1: Player one wins. 0: Player two wins.
Returns

A new Match<'a>.

Examples
use lib_rapid::math::ratings::elo::{player::EloPlayer, p_match::Match};
 
let mut beth = EloPlayer::new((1193.0, 1), 18);
let mut eric = EloPlayer::new((1213.0, 1), 25);
 
let mut first_match = Match::new(&mut beth, &mut eric, -1.0); // -1.0 is used here for not yet decided
source

pub fn update_ratings(&mut self)

Update the ratings of both players.

Examples
use lib_rapid::math::ratings::elo::{player::EloPlayer, p_match::Match};
 
let mut beth = EloPlayer::new((1193.0, 1), 18);
let mut eric = EloPlayer::new((1213.0, 1), 25);
 
let mut first_match = Match::new(&mut beth, &mut eric, -1.0); // -1.0 is used here for not yet decided
first_match.result = 1.0; // Beth wins
first_match.update_ratings();
 
assert_eq!(1214.0, beth.elo.0.round());
assert_eq!(1192.0, eric.elo.0.round());

Auto Trait Implementations§

§

impl<'a> RefUnwindSafe for Match<'a>

§

impl<'a> Send for Match<'a>

§

impl<'a> Sync for Match<'a>

§

impl<'a> Unpin for Match<'a>

§

impl<'a> !UnwindSafe for Match<'a>

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, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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.