Crates.io | stable-step |
lib.rs | stable-step |
version | 0.1.1 |
source | src |
created_at | 2022-01-14 02:43:20.980534 |
updated_at | 2022-01-14 02:43:20.980534 |
description | An implementation of Step for stable rust |
homepage | |
repository | https://git.asonix.dog/asonix/stable-step |
max_upload_size | |
id | 513626 |
size | 31,685 |
steps in stable rust
[dependencies]
stable-step = "0.1"
use stable_step::{Step, StepExt};
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord)]
enum MyEnum {
A,
B,
}
impl Step for MyEnum {
const MIN: Self = Self::A;
const MAX: Self = Self::B;
fn next(&self) -> Option<Self> {
match self {
Self::A => Some(Self::B),
_ => None,
}
}
fn prev(&self) -> Option<Self> {
match self {
Self::B => Some(Self::A),
_ => None,
}
}
}
fn main() {
for value in MyEnum::iter() {
println!("{:?}", value);
}
}
[dependencies]
stable-step = { version = "0.1", features = ["derive"] }
use stable_step::{Step, StepExt};
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Step)]
enum MyEnum {
A,
B,
}
fn main() {
for value in MyEnum::iter() {
println!("{:?}", value);
}
}