From 2aa4a82499d4becd2284cdb482213d541b8804dd Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 28 Apr 2024 16:29:10 +0200 Subject: Adding upstream version 86.0.1. Signed-off-by: Daniel Baumann --- third_party/rust/fixedbitset/src/range.rs | 39 +++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 third_party/rust/fixedbitset/src/range.rs (limited to 'third_party/rust/fixedbitset/src/range.rs') diff --git a/third_party/rust/fixedbitset/src/range.rs b/third_party/rust/fixedbitset/src/range.rs new file mode 100644 index 0000000000..aaa48961b5 --- /dev/null +++ b/third_party/rust/fixedbitset/src/range.rs @@ -0,0 +1,39 @@ +use std::ops::{ + RangeFull, + RangeFrom, + RangeTo, + Range, +}; + +// Taken from https://github.com/bluss/odds/blob/master/src/range.rs. + +/// **IndexRange** is implemented by Rust's built-in range types, produced +/// by range syntax like `..`, `a..`, `..b` or `c..d`. +pub trait IndexRange { + #[inline] + /// Start index (inclusive) + fn start(&self) -> Option { None } + #[inline] + /// End index (exclusive) + fn end(&self) -> Option { None } +} + + +impl IndexRange for RangeFull {} + +impl IndexRange for RangeFrom { + #[inline] + fn start(&self) -> Option { Some(self.start) } +} + +impl IndexRange for RangeTo { + #[inline] + fn end(&self) -> Option { Some(self.end) } +} + +impl IndexRange for Range { + #[inline] + fn start(&self) -> Option { Some(self.start) } + #[inline] + fn end(&self) -> Option { Some(self.end) } +} -- cgit v1.2.3