pub trait IntoRankShape<R>where
R: TensorRank,{
// Required method
fn into_rank_shape(
self,
) -> Result<<R as TensorRank>::Shape, ValidationError>;
}Expand description
Convert a shape container into the representation required by a tensor rank.
Dynamic rank accepts any IntoShapeVec input. For a static Rank<N>,
arrays and array references of exactly N elements convert without a
runtime rank check; vectors, slices, and ShapeVec values are checked by
TensorRank::shape_from_vec.
§Examples
use tenferro_tensor_core::{IntoRankShape, Rank};
let shape = <[usize; 2] as IntoRankShape<Rank<2>>>::into_rank_shape([2, 3])?;
assert_eq!(shape, [2, 3]);ⓘ
use tenferro_tensor_core::{IntoRankShape, Rank};
let _ = <[usize; 2] as IntoRankShape<Rank<3>>>::into_rank_shape([2, 3]);Required Methods§
Sourcefn into_rank_shape(self) -> Result<<R as TensorRank>::Shape, ValidationError>
fn into_rank_shape(self) -> Result<<R as TensorRank>::Shape, ValidationError>
Convert this shape container into R’s shape representation.
§Examples
use tenferro_tensor_core::{IntoRankShape, Rank};
let shape = <Vec<usize> as IntoRankShape<Rank<2>>>::into_rank_shape(vec![2, 3])?;
assert_eq!(shape, [2, 3]);§Errors
Returns ValidationError::RankMismatch when a vector or slice has
a length different from the static rank.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".