From e7e0246b78175a29a36610049909bc0316992f8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B5=D0=BD=D0=B8=D1=81=20=D0=9A=D0=BE=D1=82=D0=BB?= =?UTF-8?q?=D1=8F=D1=80=D0=BE=D0=B2?= Date: Fri, 8 Apr 2022 00:37:58 +0300 Subject: [PATCH] 1. Minor fixes, preparation for release. --- Cargo.toml | 2 +- src/lib.rs | 21 ++++++++++++--------- src/mem/contract.rs | 7 ++++--- src/mem/full_transmute.rs | 4 ++-- tests/easy.rs | 2 +- tests/easy_transmute.rs | 2 +- 6 files changed, 21 insertions(+), 17 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 377e7c1..484ca3f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,7 @@ license = "Apache-2.0" readme = "README.md" description = "A more complete and advanced version of data transmutation without restrictions." -keywords = ["transmute", "unsafe_transmute", "const_transmute", "cluFullTransmute", "no_std", "clucompany"] +keywords = ["transmute", "unsafe_transmute", "cluFullTransmute", "no_std", "clucompany"] categories = ["development-tools"] [dependencies] \ No newline at end of file diff --git a/src/lib.rs b/src/lib.rs index 3476b8e..d53f39f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -166,16 +166,12 @@ pub mod mem { /// Data Transformation Contract. pub mod contract; - /// Reinterprets the bits of a value of one type as another type. - /// The function is completely const, data dimensions are not checked. - pub use transmute::force_transmute as transmute; - - /// Reinterprets the bits of a value of one type as another type. - /// The function is completely const, data dimensions are not checked. + /* + Left only for compatibility with std. + */ + pub use transmute::check_sizedata_transmute as transmute; + pub use transmute::check_sizedata_transmute; pub use transmute::force_transmute; - - /// Reinterprets the bits of a value of one type as another type. - /// The function is completely const, data dimensions are not checked. pub use transmute::inline_force_transmute as inline_force_transmute; } @@ -184,3 +180,10 @@ pub mod mem { #[deprecated(since="1.0.6", note="please use `force_transmute` instead")] #[doc(hidden)] pub use self::mem::full_transmute; + +/* + Left for ease of use only. +*/ +pub use self::mem::transmute::force_transmute; +pub use self::mem::transmute::check_sizedata_transmute; +pub use self::mem::transmute::check_sizedata_transmute as transmute; diff --git a/src/mem/contract.rs b/src/mem/contract.rs index 3efdad2..7f62462 100644 --- a/src/mem/contract.rs +++ b/src/mem/contract.rs @@ -1,4 +1,5 @@ +use crate::mem::transmute::inline_force_transmute; use core::hash::Hash; use core::marker::PhantomData; use core::fmt::Debug; @@ -160,7 +161,7 @@ impl DataTransmutContract { let data_ptr: &'a T = self.as_data(); unsafe { - let new_data_ptr: &'a To = crate::mem::inline_force_transmute(data_ptr); + let new_data_ptr: &'a To = inline_force_transmute(data_ptr); new_data_ptr } } @@ -184,7 +185,7 @@ impl DataTransmutContract { // To implement permanent movement, follow these steps: let sself: Self = self; let data: T = unsafe { - crate::mem::inline_force_transmute(sself) + inline_force_transmute(sself) }; // This is allowed because we have repr transparent. @@ -198,7 +199,7 @@ impl DataTransmutContract { let data: T = self.ignore_into(); unsafe { - let result: To = crate::mem::inline_force_transmute(data); + let result: To = inline_force_transmute(data); result } } diff --git a/src/mem/full_transmute.rs b/src/mem/full_transmute.rs index 17ec56c..3f1debd 100644 --- a/src/mem/full_transmute.rs +++ b/src/mem/full_transmute.rs @@ -1,6 +1,6 @@ -use crate::mem::force_transmute; -use crate::mem::inline_force_transmute; +use crate::mem::transmute::inline_force_transmute; +use crate::force_transmute; /// Reinterprets the bits of a value of one type as another type. /// The function is completely const, data dimensions are not checked. diff --git a/tests/easy.rs b/tests/easy.rs index 9e3af7d..d876123 100644 --- a/tests/easy.rs +++ b/tests/easy.rs @@ -54,7 +54,7 @@ fn easy_full_transmute_correct() { hasher.finish() }; - let b: B = unsafe { cluFullTransmute::mem::full_transmute(a) }; + let b: B = unsafe { cluFullTransmute::mem::force_transmute(a) }; let b_hash = { let mut hasher = DefaultHasher::new(); b.hash(&mut hasher); diff --git a/tests/easy_transmute.rs b/tests/easy_transmute.rs index c8d967a..838f2fb 100644 --- a/tests/easy_transmute.rs +++ b/tests/easy_transmute.rs @@ -55,7 +55,7 @@ fn full_transmute_correct() { }; let b: B = unsafe { - cluFullTransmute::mem::full_transmute(a) + cluFullTransmute::mem::force_transmute(a) }; let b_hash = { let mut hasher = DefaultHasher::new();