Skip to main content

Crate fractions

Crate fractions 

Source
Expand description

Fraction numbers

§Compatibility

The fractions-rs crate is tested for rustc 1.70 and greater. It supports no_std environments with optional features:

[dependencies]
fractions = { version = "0.1", default-features = false }

§no_std Usage

#![no_std]
use fractions::Fraction;

fn main() {
    let a = Fraction::new(1i32, 2);
    let b = Fraction::new(1i32, 4);
    let c = a + b;
    assert_eq!(c, Fraction::new(3, 4));
}

Re-exports§

pub use fractions::const_abs;
pub use fractions::const_gcd;
pub use fractions::Fraction;

Modules§

fractions
logging
Logging utilities for fractions-rs

Functions§

archimedes
The function archimedes calculates the area of a triangle using Archimedes’ formula with the lengths of the three sides provided as Fraction<i64> values.