stats_traits 0.1.0

Traits for collection-like types to calculate statistics
Documentation
  • Coverage
  • 100%
    31 out of 31 items documented7 out of 7 items with examples
  • Size
  • Source code size: 24.21 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 635.01 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 11s Average build duration of successful builds.
  • all releases: 11s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • mrlegohead0x45/stats-traits
    1 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • mrlegohead0x45

stats

Lines of code MIT License Tests Status CodeFactor Grade

stats is a Rust statistics library

The main thing is the Stats trait which provides all the methods. It is implemented for all the collection-like types in the standard library and can be implemented for any type if that type implements IntoIterator and Clone

Examples

It works on Vectors

use stats::Stats;

fn main() {
    let my_vec = vec![1, 2, 3];
    assert_eq!(my_vec.mean(), 2);
}

To get the methods on your type

use stats::Stats;

#[derive(Clone)]
struct MyStruct {
    // ...
};

impl IntoIterator for MyStruct {
    // ...
}

impl Stats for MyStruct {}

// Now we can use the methods in `Stats`

fn main() {
    let my_struct = MyStruct {};
    println!("{}", my_struct.mean());
}