binexp 0.1.1

A struct that represents power of two numbers.
Documentation
  • Coverage
  • 30.77%
    4 out of 13 items documented3 out of 4 items with examples
  • Size
  • Source code size: 14.12 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 2.29 MB 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
  • Mirch/binexp
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • Mirch

binexp

CI crates

binexp provides a PowerOfTwo struct that you can create from any valid power of two integer.
You can use PowerOfTwo as a safe way to represent powers of two in your code.

Examples

use std::convert::TryFrom;
use binexp::PowerOfTwo;

assert!(PowerOfTwo::try_from(1).is_ok());
assert!(PowerOfTwo::try_from(2).is_ok());
assert!(PowerOfTwo::try_from(3).is_err());

let four = PowerOfTwo::try_from(4).unwrap();
assert_eq!(four.to_string(), "2^2 (4)");

let eight: PowerOfTwo = 8i8.try_into().unwrap();
assert_eq!(eight.to_string(), "2^3 (8)");

License

This project is licensed under the MIT license.