gamo 0.3.0

A Range like struct for user defined types
Documentation
  • Coverage
  • 0%
    0 out of 7 items documented0 out of 5 items with examples
  • Size
  • Source code size: 6.45 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 2.08 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 12s Average build duration of successful builds.
  • all releases: 12s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • lucidfrontier45/gamo
    1 1 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • lucidfrontier45

Gamo

Create a Range like struct of user define types for easy for loop. Gamo means range in Esperanto.

What is it?

Currently Rust does not have a stable API to create Range<T> of user defined type T. This crate provides a Range like struct Gamo that can be easily used with for-loops.

Usage

[dependencies]
gamo = "0.2.0"

The type T used in Gamo<T> must implement TryToNext trait.

Example

use gamo::{Gamo, TryToNext};

#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
struct TimeSlot(usize);

impl TryToNext for TimeSlot {
    fn try_to_next(&self) -> Option<Self> {
        Some(Self(self.0 + 1))
    }
}

fn main() {
    for t in Gamo::new(TimeSlot(0), TimeSlot(5)) {
        println!("{:?}", t);
    }
}