-
Notifications
You must be signed in to change notification settings - Fork 430
feat!: Add no_std Support
#747
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
CI issue caused by not fixing up imports in tests. Should be resolved now; tested with |
|
Hi, very nice! I have looked at the proposed changes and feel satisfied. Can you also add |
|
This PR contains breaking changes to the public Rust API. cargo-semver-checks summary |
|
I believe |
I have gone back and added |
BREAKING CHANGE: refer to petgraph#747 PR description for details on changes.
Updated CI task to highlight that `std` is required for Rust versions between 1.64 and 1.80 inclusive. For 1.81 and above, the `std` feature is not required.
A sufficient number of proposed changes have accumulated to combine them and publish a new major release numbered `0.8.0`. BREAKING CHANGE: This will require the user to provide extra type parameter in some APIs (Read more in #747). ## List of changes - [x] #747 The main innovation of the current release, the long-awaited feature that has become very relevant due to the transition of dependent projects to support `no_std`. - [x] #662 - [x] #611 - [x] #728 - [x] #686 - [x] #737 - [x] #720 - [x] #718 ## Note There are still a large number of PRs that we want to adopt in the near future, so we should expect at least a release of `0.8.1` soon after the completion of `0.8.0`. Thank you all for participating! --------- Co-authored-by: Agustin Borgna <agustinborgna@gmail.com>
The function 'zip' was introduced in petgraph#747 as a part of adding `no_std` support. However, there is already such a function in `core::iter`. The MSRV stated in the description of petgraph#747 was 1.64 at minimum, but the function in `core` is stable since Rust 1.59. Thus, it is an unnecessary duplication and can be removed without consequences.
…849) The function 'zip' was introduced in #747 as a part of adding `no_std` support. However, there is already such a function in `core::iter`. The MSRV stated in the description of #747 was 1.64 at minimum, but the function in `core` is stable since Rust 1.59. Thus, it is an unnecessary duplication and can be removed without consequences. <!-- -- Thanks for contributing to `petgraph`! -- -- We require PR titles to follow the Conventional Commits specification, -- https://www.conventionalcommits.org/en/v1.0.0/. This helps us generate -- changelogs and follow semantic versioning. -- -- Start the PR title with one of the following: -- * `feat:` for new features -- * `fix:` for bug fixes -- * `refactor:` for code refactors -- * `docs:` for documentation changes -- * `test:` for test changes -- * `perf:` for performance improvements -- * `revert:` for reverting changes -- * `ci:` for CI/CD changes -- * `chore:` for changes that don't fit in any of the above categories -- The last two categories will not be included in the changelog. -- -- If your PR includes a breaking change, please add a `!` after the type -- and include a `BREAKING CHANGE:` line in the body of the PR describing -- the necessary changes for users to update their code. -- --> Co-authored-by: cactusdualcore <cactusdualcore@noreply.codeberg.org>
…etgraph#849) The function 'zip' was introduced in petgraph#747 as a part of adding `no_std` support. However, there is already such a function in `core::iter`. The MSRV stated in the description of petgraph#747 was 1.64 at minimum, but the function in `core` is stable since Rust 1.59. Thus, it is an unnecessary duplication and can be removed without consequences. <!-- -- Thanks for contributing to `petgraph`! -- -- We require PR titles to follow the Conventional Commits specification, -- https://www.conventionalcommits.org/en/v1.0.0/. This helps us generate -- changelogs and follow semantic versioning. -- -- Start the PR title with one of the following: -- * `feat:` for new features -- * `fix:` for bug fixes -- * `refactor:` for code refactors -- * `docs:` for documentation changes -- * `test:` for test changes -- * `perf:` for performance improvements -- * `revert:` for reverting changes -- * `ci:` for CI/CD changes -- * `chore:` for changes that don't fit in any of the above categories -- The last two categories will not be included in the changelog. -- -- If your PR includes a breaking change, please add a `!` after the type -- and include a `BREAKING CHANGE:` line in the body of the PR describing -- the necessary changes for users to update their code. -- --> Co-authored-by: cactusdualcore <cactusdualcore@noreply.codeberg.org>
…etgraph#849) The function 'zip' was introduced in petgraph#747 as a part of adding `no_std` support. However, there is already such a function in `core::iter`. The MSRV stated in the description of petgraph#747 was 1.64 at minimum, but the function in `core` is stable since Rust 1.59. Thus, it is an unnecessary duplication and can be removed without consequences. <!-- -- Thanks for contributing to `petgraph`! -- -- We require PR titles to follow the Conventional Commits specification, -- https://www.conventionalcommits.org/en/v1.0.0/. This helps us generate -- changelogs and follow semantic versioning. -- -- Start the PR title with one of the following: -- * `feat:` for new features -- * `fix:` for bug fixes -- * `refactor:` for code refactors -- * `docs:` for documentation changes -- * `test:` for test changes -- * `perf:` for performance improvements -- * `revert:` for reverting changes -- * `ci:` for CI/CD changes -- * `chore:` for changes that don't fit in any of the above categories -- The last two categories will not be included in the changelog. -- -- If your PR includes a breaking change, please add a `!` after the type -- and include a `BREAKING CHANGE:` line in the body of the PR describing -- the necessary changes for users to update their code. -- --> Co-authored-by: cactusdualcore <cactusdualcore@noreply.codeberg.org>
Objective
Solution
hashbrownto a direct dependency (currently transient throughindexmap)stdfeature, and included it in all features which rely onstdfor documentation purposes.no_stdsupport works (usingwasm32v1-noneas an exampleno_stdtarget)stdusageS: BuildHasherinstead of implicitly relying onstd::hash::RandomStatewhen thestdfeature is disabledNotes
I know this has been attempted several times before and delayed due to a desire to refactor the crate first before adding this functionality. Delays in adding
no_stdsupport forced Bevy to droppetgraphfrom its core crates, relying on a specialised alternative. We'd love to keep usingpetgraph, butno_stdsupport is now a requirement going forward. This will also come up withwgpuwhich is also pursuingno_stdsupport here.BREAKING CHANGE:
Petgraph previously assumed the usage of
std::hash::RandomStateas the hashing implementation across its codebase. Inno_std, this is not possible. To minimise friction for libraries supporting bothstdandno_stdwith Petgraph, I have made the following changes to the public API:petgraph::algo::simple_paths::all_simple_pathsThis function now has a 3rd generic parameter
Swhich controls the hashing implementation used. Becauseall_simple_pathsis a function it cannot have default generic parameters, so users must specify the hasher themselves.Switched from
std::collections::{HashMap, HashSet}tohashbrown::{HashMap, HashSet}To support
no_std, we cannot use the standard library's implementations ofHashMaporHashSet. Methods and types previously referencing those collections fromstdwill now reference them fromhashbrown. Note thathashbrownwas already a dependency of Petgraph, so no change in audit requirements.Added Hashing Parameter
The following types have had a new generic parameter
Sadded to specify the hashing implementation. Note that whenstdis enabled, these will all default tostd::hash::RandomState, as before.UnGraphMapDiGraphMapMatrixGraphDiMatrixUnMatrixNodeIdentifiersNodeReferencesNote that for
MatrixGraph,DiMatrix,UnMatrixthe newSparameter is in the 3rd position (all others haveSin the last position). The reason isShas a default parameter withstdenabled, but is required withstddisabled. This means it must be the last required parameter.Also note that because
Defaultcan now be implemented for multiple versions of the above types (generic over the hasher), you may need to either specify the hasher, or explicitly declare it as default (with thestdfeature enabled):default-features = falseMSRV is 1.81If you don't enable the
stdfeature, the MSRV increases to 1.81, whencore::error::Errorwas stabilised. To preserve the original MSRV of 1.64, just enable thestdfeature.