Struct tract_hir::prelude::tract_ndarray::SliceInfo [−][src]
Expand description
Represents all of the necessary information to perform a slice.
The type T
is typically [SliceInfoElem; n]
, &[SliceInfoElem]
, or
Vec<SliceInfoElem>
. The type Din
is the dimension of the array to be
sliced, and Dout
is the output dimension after calling .slice()
. Note
that if Din
is a fixed dimension type (Ix0
, Ix1
, Ix2
, etc.), the
SliceInfo
instance can still be used to slice an array with dimension
IxDyn
as long as the number of axes matches.
Implementations
Returns a new SliceInfo
instance.
Errors if Din
or Dout
is not consistent with indices
.
For common types, a safe alternative is to use TryFrom
instead.
Safety
The caller must ensure indices.as_ref()
always returns the same value
when called multiple times.
Returns the number of dimensions of the input array for
.slice()
.
If Din
is a fixed-size dimension type, then this is equivalent to
Din::NDIM.unwrap()
. Otherwise, the value is calculated by iterating
over the SliceInfoElem
elements.
Trait Implementations
type Error = ShapeError
type Error = ShapeError
The type returned in the event of a conversion error.
pub fn try_from(
indices: &'a [SliceInfoElem]
) -> Result<SliceInfo<&'a [SliceInfoElem], Din, Dout>, ShapeError>
pub fn try_from(
indices: &'a [SliceInfoElem]
) -> Result<SliceInfo<&'a [SliceInfoElem], Din, Dout>, ShapeError>
Performs the conversion.
type Error = ShapeError
type Error = ShapeError
The type returned in the event of a conversion error.
pub fn try_from(
indices: [SliceInfoElem; 0]
) -> Result<SliceInfo<[SliceInfoElem; 0], Din, Dout>, ShapeError>
pub fn try_from(
indices: [SliceInfoElem; 0]
) -> Result<SliceInfo<[SliceInfoElem; 0], Din, Dout>, ShapeError>
Performs the conversion.
type Error = ShapeError
type Error = ShapeError
The type returned in the event of a conversion error.
pub fn try_from(
indices: [SliceInfoElem; 1]
) -> Result<SliceInfo<[SliceInfoElem; 1], Din, Dout>, ShapeError>
pub fn try_from(
indices: [SliceInfoElem; 1]
) -> Result<SliceInfo<[SliceInfoElem; 1], Din, Dout>, ShapeError>
Performs the conversion.
type Error = ShapeError
type Error = ShapeError
The type returned in the event of a conversion error.
pub fn try_from(
indices: [SliceInfoElem; 2]
) -> Result<SliceInfo<[SliceInfoElem; 2], Din, Dout>, ShapeError>
pub fn try_from(
indices: [SliceInfoElem; 2]
) -> Result<SliceInfo<[SliceInfoElem; 2], Din, Dout>, ShapeError>
Performs the conversion.
type Error = ShapeError
type Error = ShapeError
The type returned in the event of a conversion error.
pub fn try_from(
indices: [SliceInfoElem; 3]
) -> Result<SliceInfo<[SliceInfoElem; 3], Din, Dout>, ShapeError>
pub fn try_from(
indices: [SliceInfoElem; 3]
) -> Result<SliceInfo<[SliceInfoElem; 3], Din, Dout>, ShapeError>
Performs the conversion.
type Error = ShapeError
type Error = ShapeError
The type returned in the event of a conversion error.
pub fn try_from(
indices: [SliceInfoElem; 4]
) -> Result<SliceInfo<[SliceInfoElem; 4], Din, Dout>, ShapeError>
pub fn try_from(
indices: [SliceInfoElem; 4]
) -> Result<SliceInfo<[SliceInfoElem; 4], Din, Dout>, ShapeError>
Performs the conversion.
type Error = ShapeError
type Error = ShapeError
The type returned in the event of a conversion error.
pub fn try_from(
indices: [SliceInfoElem; 5]
) -> Result<SliceInfo<[SliceInfoElem; 5], Din, Dout>, ShapeError>
pub fn try_from(
indices: [SliceInfoElem; 5]
) -> Result<SliceInfo<[SliceInfoElem; 5], Din, Dout>, ShapeError>
Performs the conversion.
type Error = ShapeError
type Error = ShapeError
The type returned in the event of a conversion error.
pub fn try_from(
indices: [SliceInfoElem; 6]
) -> Result<SliceInfo<[SliceInfoElem; 6], Din, Dout>, ShapeError>
pub fn try_from(
indices: [SliceInfoElem; 6]
) -> Result<SliceInfo<[SliceInfoElem; 6], Din, Dout>, ShapeError>
Performs the conversion.
type Error = ShapeError
type Error = ShapeError
The type returned in the event of a conversion error.
pub fn try_from(
indices: [SliceInfoElem; 7]
) -> Result<SliceInfo<[SliceInfoElem; 7], Din, Dout>, ShapeError>
pub fn try_from(
indices: [SliceInfoElem; 7]
) -> Result<SliceInfo<[SliceInfoElem; 7], Din, Dout>, ShapeError>
Performs the conversion.
type Error = ShapeError
type Error = ShapeError
The type returned in the event of a conversion error.
pub fn try_from(
indices: [SliceInfoElem; 8]
) -> Result<SliceInfo<[SliceInfoElem; 8], Din, Dout>, ShapeError>
pub fn try_from(
indices: [SliceInfoElem; 8]
) -> Result<SliceInfo<[SliceInfoElem; 8], Din, Dout>, ShapeError>
Performs the conversion.
type Error = ShapeError
type Error = ShapeError
The type returned in the event of a conversion error.
pub fn try_from(
indices: Vec<SliceInfoElem, Global>
) -> Result<SliceInfo<Vec<SliceInfoElem, Global>, Din, Dout>, ShapeError>
pub fn try_from(
indices: Vec<SliceInfoElem, Global>
) -> Result<SliceInfo<Vec<SliceInfoElem, Global>, Din, Dout>, ShapeError>
Performs the conversion.
Auto Trait Implementations
impl<T, Din, Dout> RefUnwindSafe for SliceInfo<T, Din, Dout> where
Din: RefUnwindSafe,
Dout: RefUnwindSafe,
T: RefUnwindSafe,
impl<T, Din, Dout> UnwindSafe for SliceInfo<T, Din, Dout> where
Din: UnwindSafe,
Dout: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more
pub fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>ⓘimpl<W> Write for Box<W, Global> where
W: Write + ?Sized, impl<R> Read for Box<R, Global> where
R: Read + ?Sized, impl<F, A> Future for Box<F, A> where
F: Future + Unpin + ?Sized,
A: Allocator + 'static, type Output = <F as Future>::Output;impl<I, A> Iterator for Box<I, A> where
I: Iterator + ?Sized,
A: Allocator, type Item = <I as Iterator>::Item;
pub fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>ⓘimpl<W> Write for Box<W, Global> where
W: Write + ?Sized, impl<R> Read for Box<R, Global> where
R: Read + ?Sized, impl<F, A> Future for Box<F, A> where
F: Future + Unpin + ?Sized,
A: Allocator + 'static, type Output = <F as Future>::Output;impl<I, A> Iterator for Box<I, A> where
I: Iterator + ?Sized,
A: Allocator, type Item = <I as Iterator>::Item;
impl<W> Write for Box<W, Global> where
W: Write + ?Sized, impl<R> Read for Box<R, Global> where
R: Read + ?Sized, impl<F, A> Future for Box<F, A> where
F: Future + Unpin + ?Sized,
A: Allocator + 'static, type Output = <F as Future>::Output;impl<I, A> Iterator for Box<I, A> where
I: Iterator + ?Sized,
A: Allocator, type Item = <I as Iterator>::Item;
Convert Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
. Read more
Convert Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
. Read more
Convert &Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s. Read more
Convert &mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s. Read more