-
Notifications
You must be signed in to change notification settings - Fork 36
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
from and as RangeBounds #105
Conversation
Looks good! Maybe instead of Now we have to see how using this looks in all the tests and examples. |
I'm having a go at refactoring of examples with this. |
I am trying to use |
I'm probably only going to try using the |
So actually I'm having a hard time using this in ways that feel more natural than what we currently have. Even when trying different ways to write the |
I was able to use How is the |
I didn't try the advanced dependency provider repo. Instead I tried using this in the |
Yes, we where missing some let t: Range<SemanticVersion> = Range::strictly_lower_than((2, 0, 0));
assert_eq!(t, Range::from_range_bounds(&(..(2, 0, 0))));
let t: Range<SemanticVersion> = Range::higher_than((2, 0, 0));
assert_eq!(t, Range::from_range_bounds(&((2, 0, 0)..)));
let t: Range<SemanticVersion> = Range::between((1, 0, 0), (2, 0, 0));
assert_eq!(t, Range::from_range_bounds(&((1, 0, 0)..(2, 0, 0)))); The |
This testing should probably be re-done after rust-lang/rust#86031 |
@@ -88,6 +88,13 @@ impl From<&(u32, u32, u32)> for SemanticVersion { | |||
} | |||
} | |||
|
|||
// Convert an &version into a version. | |||
impl From<&SemanticVersion> for SemanticVersion { |
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.
Could this introduce stealthy clones in future code?
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.
Good thought. In this case I think it is ok.
For one thing .from()
and .into()
should probably always be thought of as "potentially as costly as a clone".
For another this is not generic, and we know the cost to clone a SemanticVersion
is small.
What do you think?
I'm not sure to follow what this is about. |
rust-lang/rust#86031 improves Std's
1/2 the number of comparisons may favor the |
I did the renaming, made clippy happy, and got the life times working! let t: Range<SemanticVersion> = Range::strictly_lower_than((2, 0, 0));
assert_eq!(t, Range::from_range_bounds(..(2, 0, 0)));
let t: Range<SemanticVersion> = Range::higher_than((2, 0, 0));
assert_eq!(t, Range::from_range_bounds((2, 0, 0)..));
let t: Range<SemanticVersion> = Range::between((1, 0, 0), (2, 0, 0));
assert_eq!(t, Range::from_range_bounds((1, 0, 0)..(2, 0, 0))); now works! |
Sorry about delay. I've had very busy weeks. I'll have some time to look at this again the weekend next week but most likely not before. |
I made the change for The ergonomic winds that justify this PR do not appear in examples:
The other major argument for this is that it can be used in generic contexts. |
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 good to me! I made small docs changes.
needs better docs and tests, but what do you think?