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

Cargo features are designed to be additive #53

Closed
bluss opened this issue Apr 1, 2016 · 3 comments · Fixed by #54
Closed

Cargo features are designed to be additive #53

bluss opened this issue Apr 1, 2016 · 3 comments · Fixed by #54

Comments

@bluss
Copy link

bluss commented Apr 1, 2016

Cargo features are designed to be additive (they add features, don't change them in a way that breaks a library). This is evident since cargo automatically uses the union of all requested features in a build.

Consider if App depends on library X that depends on nphysics, and App depends on library Y that depends on nphysics.

If library X selects the f64 feature, this changes how nphysics is compiled for the whole App's build, so Y will not compile (it was written to use f32).

@sebcrozet
Copy link
Member

I have the feeling this is a very unlikely scenario (why would an user depend directly or indirectly on nphysics twice but with different precision?) but I agree this is an abuse of Cargo feature system that has to be removed.

I guess the cleanest and most idiomatic alternative is to parametrize everything wrt. the floating-point number type. Now that 2D and 3D are on two different crates, this change should not be too complicated.

@bluss
Copy link
Author

bluss commented Apr 2, 2016

Yes I think it will be unlikely, mostly will show up when more than one user is involved of course to induce the lack of coordination. Imagine if library X and Y are separate projects by separate authors.

sebcrozet added a commit that referenced this issue Apr 2, 2016
As a side effect, this removes the need for the `f64` cargo feature.
Fix #53.
@sebcrozet
Copy link
Member

Yes, lack of coordination, of simply inattention. The most problematic consequence in a similar configuration (where the binary A uses nphysics f64 and depends on a library B that uses nphysics f32) is that compilation errors will show up for the library B instead of on the user code directly. In that case the user might mistakenly assume that the library B is faulty instead of getting that he is simply using the wrong feature.

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 a pull request may close this issue.

2 participants