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 |
| } | ||
|
|
||
| // Convert an &version into a version. | ||
| impl From<&SemanticVersion> for SemanticVersion { |
There was a problem hiding this comment.
Could this introduce stealthy clones in future code?
There was a problem hiding this comment.
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. |
mpizenberg
left a comment
There was a problem hiding this comment.
Looks good to me! I made small docs changes.
needs better docs and tests, but what do you think?