Skip to main content

Slice

Enum Slice 

Source
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.

Fields

§offset: usize
§len: usize
§

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.

Fields

§offset_from_end: usize
§len: usize
§

PositiveUnbounded

Rows offset...

Fields

§offset: NonZero<usize>

Implementations§

Source§

impl Slice

Source

pub const EMPTY: Slice

Source

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.

Source

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.

Source

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.

Source

pub fn head(n: usize) -> Slice

Create the slice of the first n rows.

Source

pub fn tail(n: usize) -> Slice

Create the slice of the last n rows.

Source

pub fn skip(n: usize) -> Option<Slice>

Create the slice of all rows after the first n.

This returns None if n is 0.

Source

pub fn len(&self) -> Option<usize>

Return the maximum number of rows selected, or None if the slice runs to the end.

Source

pub fn is_empty(&self) -> bool

Return whether no rows are selected at any height.

Source

pub fn is_positive(&self) -> bool

Return whether the slice counts from the start.

Source

pub fn is_negative(&self) -> bool

Return whether the slice counts from the end.

Source

pub fn positive_offset(&self) -> usize

Return the offset of a positive slice.

§Panics

Panics if self is Slice::Negative.

Source

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.

Source

pub fn is_within_i64(&self) -> bool

Return whether the signed offset and the end of the slice fit in an i64.

Source

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.

Source

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.

Source

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.

Source

pub fn resolve(self, n_rows: usize) -> Range<usize> ⓘ

Return which rows the slice selects from n_rows rows.

Source

pub fn restrict_to_bounds(self, n_rows: usize) -> Slice

Return the positive slice that selects the same rows from n_rows rows.

Source

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.

Source

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.

Source

pub fn fmt_tuple(&self) -> PlSmallStr

Format the slice as (offset, len), writing ∞ for the length of a slice that runs to the end.

Source

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.

Source

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.

Source

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.

Source

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§

Source§

impl Clone for Slice

Source§

fn clone(&self) -> Slice

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Slice

Source§

impl Debug for Slice

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Slice

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<Slice, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for Slice

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Eq for Slice

Source§

impl From<(i64, usize)> for Slice

Source§

fn from(_: (i64, usize)) -> Slice

Converts to this type from the input type.
Source§

impl From<(usize, usize)> for Slice

Source§

fn from(_: (usize, usize)) -> Slice

Converts to this type from the input type.
Source§

impl From<Range<usize>> for Slice

Source§

fn from(range: Range<usize>) -> Slice

Converts to this type from the input type.
Source§

impl Hash for Slice

Source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Slice

Source§

fn eq(&self, other: &Slice) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for Slice

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

impl<T> Key for T
where T: Clone,

Source§

fn align() -> usize

The alignment necessary for the key. Must return a power of two.
Source§

fn size(&self) -> usize

The size of the key in bytes.
Source§

unsafe fn init(&self, ptr: *mut u8)

Initialize the key in the given memory location. Read more
Source§

unsafe fn get<'a>(ptr: *const u8) -> &'a T

Get a reference to the key from the given memory location. Read more
Source§

unsafe fn drop_in_place(ptr: *mut u8)

Drop the key in place. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

§

impl<T> ToCompactString for T
where T: Display,

§

fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>

Fallible version of [ToCompactString::to_compact_string()] Read more
§

fn to_compact_string(&self) -> CompactString

Converts the given value to a [CompactString]. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> Ungil for T
where T: Send,

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more