Open
Description
Hi!
Recently I came to the conclusion that using the FiniteSpace trait in a generic way (when building other traits and abstractions) is quite unwieldy. I think boils down to the range()
function being at the same time not powerful enough, and quite strict due to the return type of ::std::ops::Range
.
- You can't implement
Range<CustomType>
, making it hard to implementSpace
for a custom type (i.e. an enum). Range<T>
does not implyRange<T>: Iterator<Item = T>
, requiring the need to specify this bound yourself, which is usually quite awkward. E.g.:Range<State<Self>>: Iterator<Item = State<Self>>
. If this is in a trait, it also requires all implementors to copy this. Iterating comfortably over all values in a space seems like quite useful for a finite space.
So I would propose doing something like this:
pub trait FiniteSpace: Space {
type Iter: Iterator<Item = Self::Value>;
fn iter(&self) -> Self::Iter;
}
Would you be interested in receiving PR from me applying this change?
Metadata
Metadata
Assignees
Labels
No labels