-
Notifications
You must be signed in to change notification settings - Fork 52
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
Restrict generic type of Ratio #55
Comments
These statements seem to contradict each other. If previously-working code now fails to compile, this is a breaking change, and it can happen to third-party code as well. |
I generally agree with this, but the only things that fail to compile are the
1 and 2 imply 3. Because of 3 this is not a breaking change. Does that sound right? |
Even if they can't construct it without struct Foo<T> {
ratio: Ratio<T>,
other_stuff: ...
}
impl<T: Display + Eq + One> Display for Foo<T> {
// ...
} |
I do agree that it would be nicer to be consistent with this, but it's still a breaking change. |
Hm... I hadn't thought of that. In a language with more dynamic types, I could imagine this not being a breaking change. |
Right, the additional bounds shouldn't be a problem in practice, but may require some code change to propagate the constraints throughout. So I consider this a feasible change when we do bump versions. |
Were you trying this before I had merged #48? Unfortunately, I had to drop all type constraints from those functions to let them be
|
I was working on it around the same time. Really the issue is that I tested it out on my fork that didn't have new changes from master pulled in. I guess we can save this until the issue the compiler links to is fixed. If we ever have a breaking changes tracking issue, throw this in there. |
We effectively restrict the type of Ratios by only
impl
ingnew()
andnew_raw()
onT: Clone + Integer
. This appears to work well, but putting the same restrictions on theT
in theRatio
declaration itself would make this requirement more explicit.e.g.
Testing out this change now, the compiler complains for every method in this library that uses Ratio where T is not
Clone
andInteger
(for exampleDisplay
).Unlike many of the issues I have been submitting recently, I believe this would not be a breaking change.
The text was updated successfully, but these errors were encountered: