wager 0.1.0

Primitive types and functionality for betting odds
Documentation
  • Coverage
  • 100%
    14 out of 14 items documented2 out of 5 items with examples
  • Size
  • Source code size: 46.63 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 2.34 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 13s Average build duration of successful builds.
  • all releases: 16s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Repository
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • nficca

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);