Skip to content

Commit

Permalink
1. Minor fixes, preparation for release.
Browse files Browse the repository at this point in the history
  • Loading branch information
denisandroid committed Apr 7, 2022
1 parent 612e211 commit e7e0246
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
21 changes: 12 additions & 9 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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;
7 changes: 4 additions & 3 deletions src/mem/contract.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

use crate::mem::transmute::inline_force_transmute;
use core::hash::Hash;
use core::marker::PhantomData;
use core::fmt::Debug;
Expand Down Expand Up @@ -160,7 +161,7 @@ impl<T, To> DataTransmutContract<T, To> {
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
}
}
Expand All @@ -184,7 +185,7 @@ impl<T, To> DataTransmutContract<T, To> {
// 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.
Expand All @@ -198,7 +199,7 @@ impl<T, To> DataTransmutContract<T, To> {
let data: T = self.ignore_into();

unsafe {
let result: To = crate::mem::inline_force_transmute(data);
let result: To = inline_force_transmute(data);
result
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/mem/full_transmute.rs
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion tests/easy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion tests/easy_transmute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit e7e0246

Please sign in to comment.