NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
crates.io · #1873 most downloaded on crates.io
Performs topological sorting.
Last release 2 months ago
07 Aug 2026
Ships unpredictably
gaps range from 4 weeks to 4.5 years
Nearly every release is documented
notes for 16 of 16 stable releases
Nothing withdrawn
no release was ever pulled
12 years old
16 releases · first in 2015
What's Changed Fixed Fixed broken links in README. Full Changelog : v0.3.0...v0.3.1
(Breaking Change) TopologicalSort::add_dependency() and TopologicalSort::add_link() now return true when they add a new dependency link and false when…
TopologicalSort::items() and TopologicalSort::into_items() to iterate over all remaining items, including ones that are still blocked by unresolved dependencies or cycles. (#70 by @gifnksm)Extend<DependencyLink<T>> for TopologicalSort<T>, allowing dependency links to be appended with extend(). (#63 by @gifnksm)TopologicalSort::pop_iter(), which returns a PopIter<'_, T> that repeatedly calls pop(). (#64 by @gifnksm)TopologicalSort::pop_batch(), which removes and returns the current batch of ready items and can collect into any collection implementing Default + Extend<T>. (#66, #71 by @gifnksm)TopologicalSort::peek_batch(), which iterates over the current batch of ready items. (#66, #71 by @gifnksm)TopologicalSort::remove(), which removes a specified item only when it has no remaining dependencies. (#68 by @gifnksm)CHANGELOG.md. (#51 by @gifnksm)TopologicalSort::add_dependency() and TopologicalSort::add_link() now return true when they add a new dependency link and false when that link already existed. (#39 by @szabgab)TopologicalSort<T> debug output to use a more collection-like representation of dependency relationships. (#58 by @gifnksm)#[must_use] to TopologicalSort::new(), len(), is_empty(), peek(), and peek_batch(), which may produce new warnings when their return values are ignored.TopologicalSort::pop_all() in favor of TopologicalSort::pop_batch(). (#66, #72 by @gifnksm)
Rationale:
The old name could be taken to mean that the method would keep popping items until no more progress was possible.
However, it only removed the current batch of items that had no remaining dependencies at the time of the call.
The new name makes that batch-oriented behavior explicit and helps avoid using a single pop_all() call as a cycle check.
pop_batch() also avoids unnecessary intermediate collection work.
Callers can now collect directly into their chosen container instead of always receiving a Vec.
Migration notes:
ts.pop_all() with ts.pop_batch::<Vec<_>>() when you still want a Vec.ts.pop_iter() instead, for example let items: Vec<_> = ts.pop_iter().collect();.TopologicalSort::peek_all() in favor of TopologicalSort::peek_batch(). (#66, #72 by @gifnksm)
Rationale:
The old name could be taken to mean that the method would inspect every item that would become ready as popping progressed.
However, it only inspected the current batch of items that had no remaining dependencies at the time of the call.
The new name makes that batch-oriented behavior explicit.
peek_batch() also avoids unnecessary allocation when callers only need to inspect or stream the ready items.
Migration notes:
ts.peek_all() with ts.peek_batch().collect::<Vec<_>>() when you still want Vec<&T>.peek_batch(), use ts.peek_batch().copied().collect::<Vec<_>>() for Copy types or ts.peek_batch().cloned().collect::<Vec<_>>() for Clone types.impl From<(T, T)> for DependencyLink<T>. (#57 by @gifnksm)
TopologicalSort::add_dependency(prec, succ) and DependencyLink { prec, succ }, which made it easy to invert a dependency link by mistake.ts.add_link((succ, prec).into()) with ts.add_link(DependencyLink { prec, succ }).DependencyLink::from((succ, prec)) with DependencyLink { prec, succ }..map(DependencyLink::from) on (succ, prec) tuples with .map(|(succ, prec)| DependencyLink { prec, succ }).impl FromIterator<T> for TopologicalSort<T>. (#61 by @ginksm)
TopologicalSort::from_iter(iter) or iter.collect::<TopologicalSort<T>>() compared each item with all previously seen items using partial_cmp() and inferred dependency links from every comparable pair.from_iter(), which readers could reasonably expect to just gather items or to derive relationships only from something more local such as adjacent pairs.from_iter() unexpectedly O(n^2) instead of the O(n) work that a collection-style operation usually suggests.items.into_iter().collect::<TopologicalSort<_>>().partial_cmp() defines a total order for your values and you only needed to iterate them in order, collect them into a Vec and sort it directly instead of using TopologicalSort.TopologicalSort::new() plus insert(), add_dependency(), and/or add_link().impl Iterator for TopologicalSort<T>. (#64 by @gifnksm)TopologicalSort::pop_iter() call.
TopologicalSort removes items from the sort.Iterator for TopologicalSort exposed methods such as count(), find(), and filter() directly on the sort itself.TopologicalSort, those methods look like inspection or search operations, even though calling them could destructively advance or consume the sort.pop_iter() makes that destructive step explicit.ts.next() with ts.pop() when consuming one item at a time.TopologicalSort itself with ts.pop_iter().TopologicalSort with calls on ts.pop_iter() instead.Strengthen linting and add must_use annotations by @gifnksm in #60
Use extract_if in ready-node removal paths by @gifnksm in #69
Full Changelog: v0.2.2...v0.3.0
One column per quarter.
Marked the crate as passively maintained.
Full Changelog: v0.2.1...v0.2.2
Fixed the manifest to use the supported rust-version key for declaring the MSRV.
rust-version key for declaring the MSRV.Full Changelog: v0.2.0...v0.2.1
Implemented Default for TopologicalSort<T> , allowing construction with TopologicalSort::default() . ( #20 by @gifnksm )
Default for TopologicalSort<T>, allowing construction with TopologicalSort::default(). (#20 by @gifnksm)Full Changelog: v0.1.0...v0.2.0
Default for TopologicalSort<T>, allowing construction with TopologicalSort::default().Updated CI configuration and made ignored return values explicit to satisfy newer Rust warnings. ( #16 by @gifnksm )
Full Changelog: v0.0.10...v0.1.0
Changed TopologicalSort::insert() and TopologicalSort::add_dependency() to accept arguments implementing Into<T> . ( #14 by @mathstuf )
TopologicalSort::insert() and TopologicalSort::add_dependency() to accept arguments implementing Into<T>. (#14 by @mathstuf)Full Changelog: v0.0.9...v0.0.10
Added the DependencyLink<T> type and TopologicalSort::add_link() for registering dependency edges as values. ( #11 by @mathstuf )
DependencyLink<T> type and TopologicalSort::add_link() for registering dependency edges as values. (#11 by @mathstuf)From<(T, T)> for DependencyLink<T>, allowing dependency links to be created from tuples. (#11 by @mathstuf)FromIterator<DependencyLink<T>> for TopologicalSort<T>, allowing a sorter to be built from an iterator of dependency links. (#11 by @mathstuf)Clone for TopologicalSort<T> and Copy, Clone, and Debug for DependencyLink<T>. (#13 by @gifnksm)travis-cargo helpers to direct Cargo commands.Full Changelog: v0.0.8...v0.0.9
DependencyLink<T> type and TopologicalSort::add_link() for registering dependency edges as values.From<(T, T)> for DependencyLink<T>, allowing dependency links to be created from tuples.FromIterator<DependencyLink<T>> for TopologicalSort<T>, allowing a sorter to be built from an iterator of dependency links.Clone for TopologicalSort<T> and Copy, Clone, and Debug for DependencyLink<T>.travis-cargo helpers to direct Cargo commands.Implemented fmt::Debug for TopologicalSort<T> . ( #7 by @purpleposeidon )
fmt::Debug for TopologicalSort<T>. (#7 by @purpleposeidon)TopologicalSort::peek() and TopologicalSort::peek_all() to inspect items that are ready to pop without removing them. (#7 by @purpleposeidon)Full Changelog: v0.0.7...v0.0.8
Added TopologicalSort::insert() to register elements that have no dependencies. ( #6 by @fenhl )
TopologicalSort::insert() to register elements that have no dependencies. (#6 by @fenhl)FromIterator<T> for partially ordered element types, deriving dependency edges from partial_cmp(). (#6 by @fenhl)Full Changelog: v0.0.6...v0.0.7
TopologicalSort::insert() to register elements that have no dependencies.FromIterator<T> for partially ordered element types, deriving dependency edges from partial_cmp().Added Apache-2.0 as an alternative license alongside MIT.
topological_sort in code and documentation.travis-cargo, expanded testing to nightly, beta, and stable Rust, and enabled documentation and coverage reporting.topological_sort crate name.Updated the crate for rustc 1.0.0-nightly (199bdcfef 2015-03-26).
rustc 1.0.0-nightly (199bdcfef 2015-03-26).
std_misc feature gate.Updated the crate for rustc 1.0.0-nightly (522d09dfe 2015-02-19).
rustc 1.0.0-nightly (522d09dfe 2015-02-19).
Hash.std_misc feature gate.(Breaking Change) Changed TopologicalSort::len() to return usize instead of uint.
rustc 1.0.0-dev (20bce4481 2015-01-09 04:14:53 +0000).
TopologicalSort::len() to return usize instead of uint.TopologicalSort<T> and its Iterator implementation from Hash to Hash<Hasher>.Updated the crate for rustc 1.0.0-dev (9e4e524e0 2015-01-07 05:31:23 +0000).
rustc 1.0.0-dev (9e4e524e0 2015-01-07 05:31:23 +0000).
associated_types feature gate after associated types no longer required opting in.<!-- next-url --> [Unreleased]: https://github.com/gifnksm/topological-sort-rs/compare/v0.3.1...HEAD [0.3.1]: https://github.com/gifnksm/topological-s
<!-- next-url --> [Unreleased]: https://github.com/gifnksm/topological-sort-rs/compare/v0.3.1...HEAD [0.3.1]: https://github.com/gifnksm/topological-sort-rs/compare/v0.3.0...v0.3.1 [0.3.0]: https://github.com/gifnksm/topological-sort-rs/compare/v0.2.2...v0.3.0 [0.2.2]: https://github.com/gifnksm/topological-sort-rs/compare/v0.2.1...v0.2.2 [0.2.1]: https://github.com/gifnksm/topological-sort-rs/compare/v0.2.0...v0.2.1 [0.2.0]: https://github.com/gifnksm/topological-sort-rs/compare/v0.1.0...v0.2.0 [0.1.0]: https://github.com/gifnksm/topological-sort-rs/compare/v0.0.10...v0.1.0 [0.0.10]: https://github.com/gifnksm/topological-sort-rs/compare/v0.0.9...v0.0.10 [0.0.9]: https://github.com/gifnksm/topological-sort-rs/compare/v0.0.8...v0.0.9 [0.0.8]: https://github.com/gifnksm/topological-sort-rs/compare/v0.0.7...v0.0.8 [0.0.7]: https://github.com/gifnksm/topological-sort-rs/compare/v0.0.6...v0.0.7 [0.0.6]: https://github.com/gifnksm/topological-sort-rs/compare/v0.0.5...v0.0.6 [0.0.5]: https://github.com/gifnksm/topological-sort-rs/compare/v0.0.4...v0.0.5 [0.0.4]: https://github.com/gifnksm/topological-sort-rs/compare/v0.0.3...v0.0.4 [0.0.3]: https://github.com/gifnksm/topological-sort-rs/compare/v0.0.2...v0.0.3 [0.0.2]: https://github.com/gifnksm/topological-sort-rs/compare/v0.0.1...v0.0.2 [0.0.1]: https://github.com/gifnksm/topological-sort-rs/releases/tag/v0.0.1
Your coding agent can read these notes before it upgrades. Set up the MCP server →