From 65d3b42ff9d019faf14f3ceeb9e1575bd75e3c77 Mon Sep 17 00:00:00 2001 From: Max Verevkin Date: Sun, 3 Oct 2021 20:26:34 +0300 Subject: [PATCH] make Dim trait unsafe --- src/base/dimension.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/base/dimension.rs b/src/base/dimension.rs index 8573dd59..9a51536c 100644 --- a/src/base/dimension.rs +++ b/src/base/dimension.rs @@ -55,7 +55,7 @@ impl IsNotStaticOne for Dynamic {} /// Trait implemented by any type that can be used as a dimension. This includes type-level /// integers and `Dynamic` (for dimensions not known at compile-time). -pub trait Dim: Any + Debug + Copy + PartialEq + Send + Sync { +pub unsafe trait Dim: Any + Debug + Copy + PartialEq + Send + Sync { #[inline(always)] fn is() -> bool { TypeId::of::() == TypeId::of::() @@ -74,7 +74,7 @@ pub trait Dim: Any + Debug + Copy + PartialEq + Send + Sync { fn from_usize(dim: usize) -> Self; } -impl Dim for Dynamic { +unsafe impl Dim for Dynamic { #[inline] fn try_to_usize() -> Option { None @@ -270,7 +270,7 @@ pub trait ToTypenum { type Typenum: Unsigned; } -impl Dim for Const { +unsafe impl Dim for Const { fn try_to_usize() -> Option { Some(T) }