pub enum Slice {
Positive {
offset: usize,
len: usize,
},
Negative {
offset_from_end: usize,
len: usize,
},
PositiveUnbounded {
offset: NonZero<usize>,
},
}Expand description
A selection of rows, resolved against the height of its input once that is known.
A slice from 0 that runs to the end has no variant; Option<Slice>::None stands for it.
Variants§
Positive
Rows offset..offset + len.
Negative
At most len rows, starting offset_from_end rows before the end.
A len above offset_from_end selects the same rows as len == offset_from_end.
PositiveUnbounded
Rows offset...
Implementations§
Source§impl Slice
impl Slice
pub const EMPTY: Slice
Sourcepub fn new(offset: i64, len: Option<usize>) -> Option<Slice>
pub fn new(offset: i64, len: Option<usize>) -> Option<Slice>
Create the slice of len rows from offset, counting from the end if offset is
negative. Run to the end if len is None. Return None if that selects every row.
Sourcepub fn resolve_offset(offset: i64, n_rows: usize) -> usize
pub fn resolve_offset(offset: i64, n_rows: usize) -> usize
Return the position offset refers to in n_rows rows, counting from the end if offset
is negative, clamped to 0..=n_rows.
Sourcepub fn new_positive(offset: usize, len: Option<usize>) -> Option<Slice>
pub fn new_positive(offset: usize, len: Option<usize>) -> Option<Slice>
Create the slice of len rows from offset. Run to the end if len is None. Return
None if that selects every row.
Sourcepub fn skip(n: usize) -> Option<Slice>
pub fn skip(n: usize) -> Option<Slice>
Create the slice of all rows after the first n.
This returns None if n is 0.
Sourcepub fn len(&self) -> Option<usize>
pub fn len(&self) -> Option<usize>
Return the maximum number of rows selected, or None if the slice runs to the end.
Sourcepub fn is_positive(&self) -> bool
pub fn is_positive(&self) -> bool
Return whether the slice counts from the start.
Sourcepub fn is_negative(&self) -> bool
pub fn is_negative(&self) -> bool
Return whether the slice counts from the end.
Sourcepub fn positive_offset(&self) -> usize
pub fn positive_offset(&self) -> usize
Sourcepub fn end_position(&self) -> Option<usize>
pub fn end_position(&self) -> Option<usize>
Return the number of leading rows needed to apply the slice, or None if that depends
on the height.
Sourcepub fn is_within_i64(&self) -> bool
pub fn is_within_i64(&self) -> bool
Return whether the signed offset and the end of the slice fit in an i64.
Sourcepub fn bounding_limit(&self) -> Option<Slice>
pub fn bounding_limit(&self) -> Option<Slice>
Return the smallest head or tail that contains the slice, or None if the slice
may need every row.
Sourcepub fn offsetted(self, position: usize) -> Option<Slice>
pub fn offsetted(self, position: usize) -> Option<Slice>
Return the equivalent slice to apply to the rows from position on, or None if that
would select every row.
§Panics
Panics if self is Slice::Negative.
Sourcepub fn split_front(self, n_rows: usize) -> (Range<usize>, Option<Slice>)
pub fn split_front(self, n_rows: usize) -> (Range<usize>, Option<Slice>)
Return the rows the slice selects from the next n_rows rows, and the slice to apply to
the rows after them, None if that would select every row.
§Panics
Panics if self is Slice::Negative.
Sourcepub fn resolve(self, n_rows: usize) -> Range<usize> ⓘ
pub fn resolve(self, n_rows: usize) -> Range<usize> ⓘ
Return which rows the slice selects from n_rows rows.
Sourcepub fn restrict_to_bounds(self, n_rows: usize) -> Slice
pub fn restrict_to_bounds(self, n_rows: usize) -> Slice
Return the positive slice that selects the same rows from n_rows rows.
Sourcepub fn to_signed_offset_len(&self) -> (i64, Option<usize>)
pub fn to_signed_offset_len(&self) -> (i64, Option<usize>)
Return the signed offset and the length, None if the slice runs to the end.
§Panics
Panics if the signed offset does not fit in an i64.
Sourcepub fn to_unsigned_offset_len(&self) -> (usize, Option<usize>)
pub fn to_unsigned_offset_len(&self) -> (usize, Option<usize>)
Return the offset and the length of a positive slice, None if the slice runs to the end.
§Panics
Panics if self is Slice::Negative.
Sourcepub fn fmt_tuple(&self) -> PlSmallStr
pub fn fmt_tuple(&self) -> PlSmallStr
Format the slice as (offset, len), writing ∞ for the length of a slice that runs to the
end.
Sourcepub fn to_legacy_signed_offset_len(&self) -> (i64, u64)
pub fn to_legacy_signed_offset_len(&self) -> (i64, u64)
Return the signed offset and the length, writing IdxSize::MAX for a length that runs to
the end or does not fit in an IdxSize.
Sourcepub fn reslice(self, next: Slice) -> Option<Slice>
pub fn reslice(self, next: Slice) -> Option<Slice>
Return the slice that selects the same rows as applying self and then next at every
height, or None if this pair is not combined or the result does not fit in an i64.
Sourcepub fn try_new_enclosing(a: Slice, b: Slice) -> Option<Slice>
pub fn try_new_enclosing(a: Slice, b: Slice) -> Option<Slice>
Return the smallest slice that contains both a and b at every height, or None if only
every row does.
Sourcepub fn try_within(self, outer: Slice) -> Option<Slice>
pub fn try_within(self, outer: Slice) -> Option<Slice>
Return the slice that selects the rows of self from the output of outer, or None
if outer does not contain self or if both are the same open-ended slice.
Trait Implementations§
impl Copy for Slice
Source§impl<'de> Deserialize<'de> for Slice
impl<'de> Deserialize<'de> for Slice
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Slice, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Slice, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
impl Eq for Slice
Source§impl Serialize for Slice
impl Serialize for Slice
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl StructuralPartialEq for Slice
Auto Trait Implementations§
impl Freeze for Slice
impl RefUnwindSafe for Slice
impl Send for Slice
impl Sync for Slice
impl Unpin for Slice
impl UnsafeUnpin for Slice
impl UnwindSafe for Slice
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Key for Twhere
T: Clone,
impl<T> Key for Twhere
T: Clone,
§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
ToCompactString::to_compact_string()] Read more§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
CompactString]. Read more