Skip to content
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

Add mechanisms to make builder API more convenient #1502

Merged
merged 3 commits into from
Jan 11, 2023
Merged

Add mechanisms to make builder API more convenient #1502

merged 3 commits into from
Jan 11, 2023

Conversation

hannobraun
Copy link
Owner

Add ObjectArgument a trait that abstracts over objects passed as arguments to builder API methods. Check out the commits for details, but the gist of it is, with the help of this trait, builder methods can now be used like this:

// Pass an arbitrary number of points, get an arbitrary number of edges back.
// Both argument and return values are `Vec`s of the same length.
let edges = cycle.add_edges_from_points(points);

// Pass a specific number of points, and get the same number of edges back.
let [edge_a, edge_b, edge_c] =
    cycle.add_edges_from_points([point_a, point_b, point_c]);

This makes situation in which you are working with a specific number of objects much more easy to deal with.

This pull request adds the infrastructure to do this and applies it to one builder method, simplifying a use of that builder method significantly. I expect to use this heavily going forward, as I work towards #1162.

@hannobraun hannobraun enabled auto-merge January 11, 2023 11:52
@hannobraun hannobraun merged commit cdaceb9 into main Jan 11, 2023
@hannobraun hannobraun deleted the builder branch January 11, 2023 11:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant