Crates.io | stable-step-derive |
lib.rs | stable-step-derive |
version | 0.1.0 |
source | src |
created_at | 2022-01-14 02:43:09.122522 |
updated_at | 2022-01-14 02:43:09.122522 |
description | An implementation of Step for stable rust (derive macros) |
homepage | |
repository | https://git.asonix.dog/asonix/stable-step |
max_upload_size | |
id | 513625 |
size | 3,838 |
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);
}
}