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 ConcreteShape type #401

Closed
wants to merge 2 commits into from
Closed

Add ConcreteShape type #401

wants to merge 2 commits into from

Conversation

PoignardAzur
Copy link

Supersedes #331.
Based on @ratmice's code in that PR.

Supersedes #331.
Based on @ratmice's code in that PR.
impl Shape for ConcreteShape {
type PathElementsIter<'iter> = Box<dyn Iterator<Item = crate::PathEl> + 'iter>;

fn path_elements(&self, tol: f64) -> Box<dyn Iterator<Item = crate::PathEl> + '_> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, right, this did seem more inefficient than I remembered.

@ratmice
Copy link
Contributor

ratmice commented Nov 18, 2024

I personally have no use for this code with the type modified this way since it is now a closed enum, rather than my original patch which was an open enum due to the generic parameter. This makes the type not useful for a library, when the library is intended to be used by a crate that implements the Shape trait.

@PoignardAzur
Copy link
Author

We'll see in practice whether people have use for it. I already know it's going to be useful in Masonry.

@ratmice
Copy link
Contributor

ratmice commented Nov 19, 2024

There is nothing here trait wise which requires the implementation to be in kurbo itself. IMO without supporting downstream implementations of the Shape trait if this is useful in Masonry, it is better to just put the implementation in Masonry. Would it's usefulness there even require it being pub?

@waywardmonkeys
Copy link
Contributor

I also don't really understand what problem in masonry this is going to be solving to know how to evaluate that.

Why can't some experimentation happen with a version of this within masonry for now since we would otherwise have to do a release of Kurbo and hope that the API was both right and useful?

@PoignardAzur
Copy link
Author

Well we could always stick to the version introduced in linebender/xilem#591

@ratmice
Copy link
Contributor

ratmice commented Nov 21, 2024

I definitely feel that I would prefer downstream crates adopting ad-hoc solutions over
inclusion of a solution in kurbo that only works with Kurbo included implementations of the trait.

That is to say, that this is working around an issue with the Shape trait not being object-safe,
The proposition with object safety is something like forall t: Trait, ObjectSafe(t) -> exists dyn Trait.
This patch by being limited to kurbo specific variants for the Shape impls, doesn't apply in all the cases that forall would.

Thus my feeling is that this patch doesn't fix the problem, it only fixes the common occurrences of the problem.
In doing so, it would seem to kill any motivation towards actually fixing the problem...

I would rather not see this included lightly based on it's convenience,
Fixing it in downstream libraries like masonry isn't convenient or ideal,
it in fact impedes code sharing across libraries that depend upon kurbo,
but ensures that there is motivation to fix it properly, and avoids hamstringing kurbo to something silly should we decide to re-adopt object safety for the trait or some other option...

Apologies if i'm being overly difficult in this regard...

@PoignardAzur
Copy link
Author

Overall, there's been little enough enthusiasm for this feature that I'd rather close the PR for now.

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.

4 participants