wager

Crates.iowager
lib.rswager
version0.1.1
created_at2025-02-24 02:17:21.039982+00
updated_at2025-03-01 15:39:15.363654+00
descriptionPrimitive types and functionality for betting odds
homepage
repositoryhttps://github.com/nficca/wager
max_upload_size
id1566817
size48,068
Nic Ficca (nficca)

documentation

README

wager

A library for the representation and manipulation of betting odds. Supports the parsing, converting, comparing, and calculating the payouts of various types of odds.

Basic usage

use wager::odd::{Decimal, Fractional, Moneyline, Odd, AnyOdd};

// Parse
let moneyline = "-200".parse::<Moneyline>().unwrap();

// Convert
let decimal = Decimal::try_from(moneyline).unwrap();

// Compare
let a = "+300".parse::<AnyOdd>().unwrap();
let b = "3/1".parse::<AnyOdd>().unwrap();
assert_eq!(a, b);

/// Calculate payout
assert_eq!(decimal.payout(200.0), 300.0);
Commit count: 45

cargo fmt