forked from bevyengine/bevy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Address some feedback for the bevy_tasks PR - Add a general clamp fn to bevy_math - Expose num_cpus in bevy_tasks - Fill out empty doc comment * Add comments and clean up pinning in bevy_tasks, fix a couple tests
- Loading branch information
Showing
7 changed files
with
69 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/// A value bounded by a minimum and a maximum | ||
/// | ||
/// If input is less than min then this returns min. | ||
/// If input is greater than max then this returns max. | ||
/// Otherwise this returns input. | ||
/// | ||
/// **Panics** in debug mode if `!(min <= max)`. | ||
/// | ||
/// Original implementation from num-traits licensed as MIT | ||
pub fn clamp<T: PartialOrd>(input: T, min: T, max: T) -> T { | ||
debug_assert!(min <= max, "min must be less than or equal to max"); | ||
if input < min { | ||
min | ||
} else if input > max { | ||
max | ||
} else { | ||
input | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters