Async Entity Component System based on the ideas of specs (https://github.com/amethyst/specs)
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

32 строки
866 B

  1. mod try_;
  2. pub use try_::Try;
  3. use std::ops::{Bound, Range, RangeBounds};
  4. pub fn simplify_range(range: impl RangeBounds<usize>, len: usize) -> Range<usize> {
  5. let start = match range.start_bound() {
  6. Bound::Unbounded => 0,
  7. Bound::Included(&i) if i <= len => i,
  8. Bound::Excluded(&i) if i < len => i + 1,
  9. bound => panic!("range start {:?} should be <= length {}", bound, len),
  10. };
  11. let end = match range.end_bound() {
  12. Bound::Unbounded => len,
  13. Bound::Excluded(&i) if i <= len => i,
  14. Bound::Included(&i) if i < len => i + 1,
  15. bound => panic!("range end {:?} should be <= length {}", bound, len),
  16. };
  17. if start > end {
  18. panic!(
  19. "range start {:?} should be <= range end {:?}",
  20. range.start_bound(),
  21. range.end_bound()
  22. );
  23. }
  24. start..end
  25. }