-
Notifications
You must be signed in to change notification settings - Fork 3
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
feat!: Use RPITIT for graph traits #156
Conversation
This PR contains breaking changes to the public Rust API. cargo-semver-checks summary
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #156 +/- ##
==========================================
- Coverage 80.63% 80.49% -0.14%
==========================================
Files 22 22
Lines 5168 5158 -10
Branches 5168 5158 -10
==========================================
- Hits 4167 4152 -15
- Misses 928 933 +5
Partials 73 73 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, some nits and questions.
benches/benchmarks/portgraph.rs
Outdated
.nodes_iter() | ||
.collect_vec() | ||
.into_iter() | ||
.cycle() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is because nodes_iter()
doesn't return an iterator with Clone
. Kind of gross, but I guess this is fine. Did you consider nodes_iter() -> impl Iterator + Clone
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably do that. Iterators are normally clonable, so it shouldn't be too problematic
fn node_port_capacity(&self, node: NodeIndex) -> usize { | ||
self.graph.node_port_capacity(node) | ||
delegate! { | ||
to (self.graph) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should these have #[inline]
annotations?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delegate
does that automatically!
Inserts #[inline(always)] automatically (unless you specify #[inline] manually on the method)
src/multiportgraph/iter.rs
Outdated
#[inline] | ||
/// Returns an iterator over every pair of matching ports connecting `from` | ||
/// with `to`. | ||
pub fn _get_connections(&self, from: NodeIndex, to: NodeIndex) -> NodeConnections { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are these functions pub
? They are "Used internally".
I'm not a huge fan of these _...
functions, but I don't have a better suggestion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't think about it since it was in a private module, but they should be pub(crate)
instead 👍
I agree that these are annoying to have. In an ideal world we'd be able to use #[refine]
instead...
https://rust-lang.github.io/rfcs/3245-refined-impls.html
src/multiportgraph.rs
Outdated
#[inline] | ||
fn get_connections(&self, from: NodeIndex, to: NodeIndex) -> Self::NodeConnections<'_> { | ||
NodeConnections::new(self, to, self.output_links(from)) | ||
fn get_connections( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think all of these functions could be
delegate! {
to self {
#[call(_get_connections)]
fn get_connections(...);
}
}
If you prefer as is that is fine.
@@ -95,39 +95,39 @@ macro_rules! impl_petgraph_traits { | |||
} | |||
|
|||
impl<'g, $($args)*> petgraph::visit::IntoNodeIdentifiers for &'g $graph where $($where)* { | |||
type NodeIdentifiers = <$graph as PortView>::Nodes<'g>; | |||
type NodeIdentifiers = Box<dyn Iterator<Item = NodeIndex> + 'g>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a shame.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes...
We need petgraph 0.7
with RPITIT in its traits -.-'
## 🤖 New release * `portgraph`: 0.12.3 -> 0.13.0 (⚠️ API breaking changes) ###⚠️ `portgraph` breaking changes ``` --- failure auto_trait_impl_removed: auto trait no longer implemented --- Description: A public type has stopped implementing one or more auto traits. This can break downstream code that depends on the traits being implemented. ref: https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.38.0/src/lints/auto_trait_impl_removed.ron Failed in: type EdgeRefs is no longer Send, in /tmp/.tmpncG4Dv/portgraph/src/view/petgraph.rs:326 type EdgeRefs is no longer Sync, in /tmp/.tmpncG4Dv/portgraph/src/view/petgraph.rs:326 type EdgeRefs is no longer UnwindSafe, in /tmp/.tmpncG4Dv/portgraph/src/view/petgraph.rs:326 type EdgeRefs is no longer RefUnwindSafe, in /tmp/.tmpncG4Dv/portgraph/src/view/petgraph.rs:326 type NodeEdgeRefs is no longer Send, in /tmp/.tmpncG4Dv/portgraph/src/view/petgraph.rs:396 type NodeEdgeRefs is no longer Sync, in /tmp/.tmpncG4Dv/portgraph/src/view/petgraph.rs:396 type NodeEdgeRefs is no longer UnwindSafe, in /tmp/.tmpncG4Dv/portgraph/src/view/petgraph.rs:396 type NodeEdgeRefs is no longer RefUnwindSafe, in /tmp/.tmpncG4Dv/portgraph/src/view/petgraph.rs:396 --- failure inherent_method_missing: pub method removed or renamed --- Description: A publicly-visible method or associated fn is no longer available under its prior name. It may have been renamed or removed entirely. ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.38.0/src/lints/inherent_method_missing.ron Failed in: FilteredGraph::new_region, previously in file /tmp/.tmpJ9kcgB/portgraph/src/view/region.rs:26 FilteredGraph::new_flat_region, previously in file /tmp/.tmpJ9kcgB/portgraph/src/view/region.rs:105 FilteredGraph::new_subgraph, previously in file /tmp/.tmpJ9kcgB/portgraph/src/view/subgraph.rs:73 FilteredGraph::is_convex, previously in file /tmp/.tmpJ9kcgB/portgraph/src/view/subgraph.rs:100 FilteredGraph::is_convex_with_checker, previously in file /tmp/.tmpJ9kcgB/portgraph/src/view/subgraph.rs:106 FilteredGraph::new_region, previously in file /tmp/.tmpJ9kcgB/portgraph/src/view/region.rs:26 FilteredGraph::new_flat_region, previously in file /tmp/.tmpJ9kcgB/portgraph/src/view/region.rs:105 FilteredGraph::new_subgraph, previously in file /tmp/.tmpJ9kcgB/portgraph/src/view/subgraph.rs:73 FilteredGraph::is_convex, previously in file /tmp/.tmpJ9kcgB/portgraph/src/view/subgraph.rs:100 FilteredGraph::is_convex_with_checker, previously in file /tmp/.tmpJ9kcgB/portgraph/src/view/subgraph.rs:106 --- failure module_missing: pub module removed or renamed --- Description: A publicly-visible module cannot be imported by its prior path. A `pub use` may have been removed, or the module may have been renamed, removed, or made non-public. ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.38.0/src/lints/module_missing.ron Failed in: mod portgraph::py_graph, previously in file /tmp/.tmpJ9kcgB/portgraph/src/py_graph.rs:1 mod portgraph::view::subgraph, previously in file /tmp/.tmpJ9kcgB/portgraph/src/view/subgraph.rs:1 mod portgraph::view::region, previously in file /tmp/.tmpJ9kcgB/portgraph/src/view/region.rs:1 --- failure struct_missing: pub struct removed or renamed --- Description: A publicly-visible struct cannot be imported by its prior path. A `pub use` may have been removed, or the struct itself may have been renamed or removed entirely. ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.38.0/src/lints/struct_missing.ron Failed in: struct portgraph::view::region::RegionContext, previously in file /tmp/.tmpJ9kcgB/portgraph/src/view/region.rs:35 struct portgraph::view::filter::FilteredGraphCtx, previously in file /tmp/.tmpJ9kcgB/portgraph/src/view/filter.rs:131 struct portgraph::view::subgraph::SubgraphContext, previously in file /tmp/.tmpJ9kcgB/portgraph/src/view/subgraph.rs:53 --- failure trait_removed_associated_type: trait's associated type was removed --- Description: A public trait's associated type was removed or renamed. ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.38.0/src/lints/trait_removed_associated_type.ron Failed in: associated type LinkView::Neighbours, previously at /tmp/.tmpJ9kcgB/portgraph/src/view.rs:291 associated type LinkView::NodeConnections, previously at /tmp/.tmpJ9kcgB/portgraph/src/view.rs:296 associated type LinkView::NodeLinks, previously at /tmp/.tmpJ9kcgB/portgraph/src/view.rs:302 associated type LinkView::PortLinks, previously at /tmp/.tmpJ9kcgB/portgraph/src/view.rs:308 associated type LinkView::Neighbours, previously at /tmp/.tmpJ9kcgB/portgraph/src/view.rs:291 associated type LinkView::NodeConnections, previously at /tmp/.tmpJ9kcgB/portgraph/src/view.rs:296 associated type LinkView::NodeLinks, previously at /tmp/.tmpJ9kcgB/portgraph/src/view.rs:302 associated type LinkView::PortLinks, previously at /tmp/.tmpJ9kcgB/portgraph/src/view.rs:308 associated type MultiView::NodeSubports, previously at /tmp/.tmpJ9kcgB/portgraph/src/view.rs:589 associated type MultiView::NodeSubports, previously at /tmp/.tmpJ9kcgB/portgraph/src/view.rs:589 associated type PortView::Nodes, previously at /tmp/.tmpJ9kcgB/portgraph/src/view.rs:22 associated type PortView::Ports, previously at /tmp/.tmpJ9kcgB/portgraph/src/view.rs:27 associated type PortView::NodePorts, previously at /tmp/.tmpJ9kcgB/portgraph/src/view.rs:32 associated type PortView::NodePortOffsets, previously at /tmp/.tmpJ9kcgB/portgraph/src/view.rs:37 associated type PortView::Nodes, previously at /tmp/.tmpJ9kcgB/portgraph/src/view.rs:22 associated type PortView::Ports, previously at /tmp/.tmpJ9kcgB/portgraph/src/view.rs:27 associated type PortView::NodePorts, previously at /tmp/.tmpJ9kcgB/portgraph/src/view.rs:32 associated type PortView::NodePortOffsets, previously at /tmp/.tmpJ9kcgB/portgraph/src/view.rs:37 ``` <details><summary><i><b>Changelog</b></i></summary><p> <blockquote> ## [0.13.0](v0.12.3...v0.13.0) - 2025-01-17 ### New Features - [**breaking**] Use RPITIT for graph traits (#156) - [**breaking**] Boundary order checking (#164) ### Performance - [**breaking**] Fix Subgraph O(n) complexity (#157) - [**breaking**] Manual impl of `Region`/`FlatRegion` for improved perf (#162) </blockquote> </p></details> --- This PR was generated with [release-plz](https://github.com/release-plz/release-plz/). --------- Co-authored-by: Agustín Borgna <[email protected]>
Closes #119
This should simplify the implementation of #155, and any other new wrapper.
BREAKING CHANGE: Graph trait methods now return
impl Iterator
s instead of named associated types.