- The
exhaust-macrospackage no longer depends onitertools. This may improve build parallelism, and if cross-compiling, avoids buildingitertoolsfor the host as well as the target. - The dependency on
itertoolscan now use version 0.15, in addition to versions 0.13 through 0.14. This has no effect on the functionality ofexhaust.
impl Exhaust for core::num::Saturating- Iterators for several standard library enums now implement
ExactSizeIterator. - Iterators for
NonZero<u*>now implementDoubleEndedIteratorandExactSizeIterator.
- Iterators for
BTreeSetandHashSetnow produce their elements (sets) in the order that is sorted according toBTreeSet’sOrdimplementation, rather than producing the sets in order from smallest to largest. This follows the general recommendation for allExhaustimplementations. (BTreeMap’s andHashMap’s ordering have also changed, but it is not yet the case thatBTreeMapexhaustion occurs in sorted order.) - Corrected incorrect bounds on a
FusedIteratorimplementation. (It is not possible to obtain a misbehaving value of this undocumented type, but this change could technically cause some code to stop compiling.)
- Iterators for
NonZero<u*>have been simplified. - Iterators for
NonZero<i*>now have an improved but not perfectsize_hint(). exhaust::Iternow forwardsnth(),nth_back(), andlast()to the underlying iterator.
#[derive(Exhaust)]now supports a configuration attribute#[exhaust(factory_is_self)], which disables generation of a separateExhaust::Factorytype. This can be used to simplify the macro-generated code to improve build performance, but requires the type and its fields to implementCloneandDebug, similar to what was required inexhaustv0.1; see the derive macro’s documentation for details.
derive(Exhaust)iterators now implementsize_hint()exactly in some cases; most notably, fieldless enums. (They still do not implementExactSizeIterator.)derive(Exhaust)iterators now take up less memory when a struct, or a variant of an enum, has exactly one field.
derive(Exhaust)now supports types with const generic parameters.
derive(Exhaust)will no longer produce spurious warnings when the type of a field is uninhabited.
derive(Exhaust)generates simpler code to improve build performance (and readability).- Replaced use of
Option::unwrap()with pattern matching. - Replaced recursion in enum iterator
next()with iteration. - Factories for unit structs no longer include an inner type.
- Removed superfluous
&& trues.
- Replaced use of
This release was published erroneously and is functionally equivalent to 0.2.2.
-
impl Exhaust for ...core::fmt::Alignmentcore::fmt::Errorcore::cell::OnceCellcore::ops::Boundcore::ops::ControlFlowcore::ops::RangeFromcore::ops::RangeFullcore::ops::RangeTocore::ops::RangeToInclusivestd::sync::OnceLockstd::sync::mpsc::RecvErrorstd::sync::mpsc::RecvTimeoutErrorstd::sync::mpsc::SendErrorstd::sync::mpsc::TryRecvErrorstd::sync::mpsc::TrySendError
-
The dependency on
itertoolscan now use either version 0.14 or version 0.13. This has no effect on the functionality ofexhaust.
Cell<T>implementsExhausteven whenTdoes not implementCopy.- Documentation contains examples for the
Exhaustderive macro anditeration::carry.
- The macro-generated types are now always named
Exhaust<your type name><some suffix>. This makes it possible to reliably avoid name conflicts in the narrow case that they can happen, and is more systematic than the previous naming scheme. - Explicitly
allow(nonstandard_style)in macro generated code. Together with the above name change, this should prevent lint from the macro-generated code when using rust-analyzer.
The Exhaust trait no longer requires Self: Clone.
This allows it to be implemented for many more types, such as Mutex and Atomic*,
which can be constructed with arbitrary data but not cloned.
In order to support this, the Exhaust trait now separates iteration over the possible data
(which still must be cloneable) from construction of the final value.
The new definition of the trait is:
pub trait Exhaust: Sized {
type Iter: FusedIterator<Item = Self::Factory> + Clone;
type Factory: Clone; // New
// Required methods
fn exhaust_factories() -> Self::Iter; // New
fn from_factory(factory: Self::Factory) -> Self; // New
// Provided method
fn exhaust() -> impl Iterator<Item = Self>;
}The Factory is the cloneable data, so named since it is a means of constructing many Self.
Implementors must return an iterator which produces Factory instead of Self.
They may then perform the final construction in from_factory().
Existing implementations may be migrated by adding type Factory = Self
and renaming fn exhaust() to fn exhaust_factories().
However, it may be possible to simplify the iterator by moving some code into fn from_factory().
-
impl Exhaust for ...core::cell::UnsafeCellcore::sync::AtomicBoolcore::sync::Atomic{U,I}{8,16,32}alloc::borrow::Cow<'_ T>, whenTimplements onlyToOwnedrather thanClone.std::io::BufReaderstd::io::BufWriterstd::io::Chainstd::io::LineWriterstd::io::Repeatstd::io::Sinkstd::io::Stderrstd::io::Stdinstd::io::Stdout
-
exhaust::Iter<T>is a single generic iterator for allT: Exhaust. It is now the type returned byExhaust::exhaust().
- The minimum supported Rust version is now 1.80.
- Breaking: The derive macro
derive(Exhaust)now hides its generated items. They can only be accessed through the trait implementation’s associated types. - Breaking:
Exhaust::Itertypes now must implementDebugandFusedIterator.
<Option<T> as Exhaust>::Iterno longer implementsDoubleEndedIterator. This might be added back in the future.- Removed
exhaust::ExhaustArrayfrom the crate root. - Removed
exhaust::brute_force_search(). - Removed the public module
exhaust::impls. The iterators can only be accessed through the trait implementation’s associated types.
There are no changes to functionality in this release.
- Improved documentation.
- Depends on
itertoolsversion 0.13 instead of 0.10. - Added
rust-version(minimum supported Rust version) information, chosen to be 1.60. exhaust::ExhaustArrayis now marked as#[deprecated](useexhaust::impls::ExhaustArrayinstead).
impl Exhaust for ...- Tuples of length up to 12
core::cell::Cellcore::cell::RefCellcore::cmp::Orderingcore::future::Pendingcore::future::Readycore::hash::BuildHasherDefaultcore::iter::Reversecore::marker::PhantomPinnedcore::num::FpCategorycore::num::NonZero*core::result::Resultcore::task::Pollalloc::borrow::Cowalloc::collections::BTreeMapalloc::collections::BTreeSet- Note: Does not produce lexicographic ordering.
Pin<Box<T>>std::collections::HashMapstd::collections::HashSetstd::io::Cursorstd::io::Emptystd::io::Sink
- Documentation example of a custom
impl Exhaust.
derive(Exhaust)generates more detailed documentation for the iterator.
- Added license texts.
- Configured GitHub Actions CI.
Initial public release.