pub struct SaturatedSlice { /* private fields */ }Expand description
A saturated slice with values ranging in [isize::MIN, isize::MAX]. Used for sliceable sequences that require indices in the aforementioned range.
Invokes __index__ on the PySliceRef during construction so as to separate the
transformation from PyObject into isize and the adjusting of the slice to a given
sequence length. The reason this is important is due to the fact that an objects
__index__ might get a lock on the sequence and cause a deadlock.
Implementations§
Source§impl SaturatedSlice
impl SaturatedSlice
pub const fn from_parts(start: isize, stop: isize, step: isize) -> Self
pub const fn start(&self) -> isize
pub const fn stop(&self) -> isize
pub const fn step(&self) -> isize
pub fn with_slice(slice: &Py<PySlice>, vm: &VirtualMachine) -> PyResult<Self>
Sourcepub fn adjust_indices(&self, len: usize) -> (Range<usize>, isize, usize)
pub fn adjust_indices(&self, len: usize) -> (Range<usize>, isize, usize)
Convert for usage in indexing the underlying rust collections. Called after index has been called on the Slice which might mutate the collection.
Sourcepub fn adjust_indices_start(&self, len: usize) -> (isize, usize)
pub fn adjust_indices_start(&self, len: usize) -> (isize, usize)
The index the slice begins at, clamped into 0..=len for a positive step
and into -1..=len-1 for a negative one, together with its length.
Unlike Self::adjust_indices this stays meaningful for an empty slice,
where it is still the position a strided view moves to.
pub fn iter(&self, len: usize) -> SaturatedSliceIter ⓘ
Trait Implementations§
Source§impl Clone for SaturatedSlice
impl Clone for SaturatedSlice
impl Copy for SaturatedSlice
Auto Trait Implementations§
impl Freeze for SaturatedSlice
impl RefUnwindSafe for SaturatedSlice
impl Send for SaturatedSlice
impl Sync for SaturatedSlice
impl Unpin for SaturatedSlice
impl UnsafeUnpin for SaturatedSlice
impl UnwindSafe for SaturatedSlice
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> ErasedDestructor for Twhere
T: 'static,
impl<T> Helper for T
Source§impl<T, U> ImaginaryInto<U> for Twhere
U: ImaginaryFrom<T>,
impl<T, U> ImaginaryInto<U> for Twhere
U: ImaginaryFrom<T>,
fn imaginary_into(self) -> U
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 more