Skip to content

Commit ad856bd

Browse files
committed
FEAT: Special case D::from_dimension for Ix1
1 parent f998a62 commit ad856bd

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

src/dimension/dimension_trait.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,14 @@ impl Dimension for Dim<[Ix; 1]> {
540540
fn try_remove_axis(&self, axis: Axis) -> Self::Smaller {
541541
self.remove_axis(axis)
542542
}
543+
544+
fn from_dimension<D2: Dimension>(d: &D2) -> Option<Self> {
545+
if 1 == d.ndim() {
546+
Some(Ix1(d[0]))
547+
} else {
548+
None
549+
}
550+
}
543551
private_impl! {}
544552
}
545553

0 commit comments

Comments
 (0)