cents 0.1.1

A small crate for handling monetary values as in integer number of cents.
Documentation
  • Coverage
  • 0%
    0 out of 3 items documented0 out of 2 items with examples
  • Size
  • Source code size: 6.9 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 252.0 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 14s Average build duration of successful builds.
  • all releases: 14s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • buckeye/cents
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • scull7

cents

A small crate for handling monetary values as in integer number of cents.

Example Usage

use cents::Cents;

// Create a new cents object directly.
let money = Cents::new(21, 21);

// compare it against a cents object created from a u64 value.
assert_eq!(Cents::new(42, 42), 4242.into());


// add it to an u64 value.
assert_eq!(money + 2121, Cents::new(42, 42);

// Add two cents
assert_eq!(Cents::from(2121) + Cents::from(2121), Cents::new(42, 42));

Features

  • Addition (Self, u64)
  • Subtraction (Self)
  • Multiplication (Self, u64)
  • Conversion from BigInt
  • Conversion from u64
  • Equality (Self)