-
-
Notifications
You must be signed in to change notification settings - Fork 558
Various refactorings #1470
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
base: main
Are you sure you want to change the base?
Various refactorings #1470
Changes from 2 commits
3e8e5d2
8d6129c
497f283
6b569f2
24c8e3c
b9e0ff9
4d8d0d9
3db6769
08e34d7
b6ebe64
c97b069
3927acf
e37f299
d5d01f5
bcbc450
f22072c
e5215af
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -339,27 +339,13 @@ pub fn partial_ge<T: PartialOrd>(a: &T, b: &T) -> bool { | |
| /// Return the minimum of `a` and `b` if they are comparable. | ||
| #[inline] | ||
| pub fn partial_min<'a, T: PartialOrd>(a: &'a T, b: &'a T) -> Option<&'a T> { | ||
| if let Some(ord) = a.partial_cmp(b) { | ||
| match ord { | ||
| Ordering::Greater => Some(b), | ||
| _ => Some(a), | ||
| } | ||
| } else { | ||
| None | ||
| } | ||
| a.partial_cmp(b).map(|ord| if ord.is_ge() { b } else { a }) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To avoid a change in behavior, this should be
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the correct behavior,
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's incorrect. The "e" stands for "equals", as in "greater or equals". This is illustrated in the documentation. |
||
| } | ||
|
|
||
| /// Return the maximum of `a` and `b` if they are comparable. | ||
| #[inline] | ||
| pub fn partial_max<'a, T: PartialOrd>(a: &'a T, b: &'a T) -> Option<&'a T> { | ||
| if let Some(ord) = a.partial_cmp(b) { | ||
| match ord { | ||
| Ordering::Less => Some(b), | ||
| _ => Some(a), | ||
| } | ||
| } else { | ||
| None | ||
| } | ||
| a.partial_cmp(b).map(|ord| if ord.is_le() { b } else { a }) | ||
| } | ||
|
|
||
| /// Clamp `value` between `min` and `max`. Returns `None` if `value` is not comparable to | ||
|
|
@@ -382,14 +368,8 @@ pub fn partial_clamp<'a, T: PartialOrd>(value: &'a T, min: &'a T, max: &'a T) -> | |
| /// Sorts two values in increasing order using a partial ordering. | ||
| #[inline] | ||
| pub fn partial_sort2<'a, T: PartialOrd>(a: &'a T, b: &'a T) -> Option<(&'a T, &'a T)> { | ||
| if let Some(ord) = a.partial_cmp(b) { | ||
| match ord { | ||
| Ordering::Less => Some((a, b)), | ||
| _ => Some((b, a)), | ||
| } | ||
| } else { | ||
| None | ||
| } | ||
| a.partial_cmp(b) | ||
| .map(|ord| if ord.is_le() { (a, b) } else { (b, a) }) | ||
| } | ||
|
|
||
| /* | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.