| Crates.io | wager |
| lib.rs | wager |
| version | 0.1.1 |
| created_at | 2025-02-24 02:17:21.039982+00 |
| updated_at | 2025-03-01 15:39:15.363654+00 |
| description | Primitive types and functionality for betting odds |
| homepage | |
| repository | https://github.com/nficca/wager |
| max_upload_size | |
| id | 1566817 |
| size | 48,068 |
A library for the representation and manipulation of betting odds. Supports the parsing, converting, comparing, and calculating the payouts of various types of odds.
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);