Unverified Commit b302ebcf authored by Hero Bird's avatar Hero Bird Committed by GitHub

Move collections/boxed to alloc/boxed (#415)

* [core] move collections/boxed module to alloc module

* [core] move main docs from boxed module to Box struct

* [core] properly relink moved module

* [core] remove unnecessary #Safety docs (not related to PR)

* [core] apply rustfmt
parent 26b344fb
Pipeline #93831 passed with stages
in 8 minutes and 4 seconds
......@@ -12,24 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//! A dynamically allocated storage entity.
//!
//! Users can use this in order to make certain `SpreadLayout` storage entities
//! used in contexts that require a `PackedLayout` storage entity by simply
//! packing the storage entity witihn a `storage::Box`.
//!
//! Dynamic allocations caused by the creation of `storage::Box` instances do
//! have some limited overhead:
//!
//! - The dynamic allocation itself has to be provided by some dynamic storage
//! allocator that needs to be invoked.
//! - Each dynamic storage allocation implies roughly 1.12 bits of overhead.
//! - Upon ever first dereferencing of a `storage::Box` instance a cryptographic
//! hash routine is run in order to compute the underlying storage key.
//!
//! Use this abstraction with caution due to the aforementioned performance
//! implications.
mod impls;
mod storage;
......@@ -46,7 +28,23 @@ use crate::storage2::{
};
use ink_primitives::Key;
/// An indirection to some dynamically allocated storage entity.
/// A dynamically allocated storage entity.
///
/// Users can use this in order to make certain `SpreadLayout` storage entities
/// used in contexts that require a `PackedLayout` storage entity by simply
/// packing the storage entity witihn a `storage::Box`.
///
/// Dynamic allocations caused by the creation of `storage::Box` instances do
/// have some limited overhead:
///
/// - The dynamic allocation itself has to be provided by some dynamic storage
/// allocator that needs to be invoked.
/// - Each dynamic storage allocation implies roughly 1.12 bits of overhead.
/// - Upon ever first dereferencing of a `storage::Box` instance a cryptographic
/// hash routine is run in order to compute the underlying storage key.
///
/// Use this abstraction with caution due to the aforementioned performance
/// implications.
#[derive(Debug)]
pub struct Box<T>
where
......
......@@ -70,6 +70,7 @@
mod allocation;
mod allocator;
mod boxed;
mod init;
#[cfg(test)]
......@@ -78,6 +79,7 @@ mod tests;
use self::allocator::DynamicAllocator;
pub use self::{
allocation::DynamicAllocation,
boxed::Box,
init::ContractPhase,
};
......
......@@ -20,7 +20,6 @@
pub mod bitstash;
pub mod bitvec;
pub mod boxed;
pub mod hashmap;
pub mod smallvec;
pub mod stash;
......@@ -30,7 +29,6 @@ pub mod vec;
pub use self::{
bitstash::BitStash,
bitvec::Bitvec,
boxed::Box,
hashmap::HashMap,
smallvec::SmallVec,
stash::Stash,
......
......@@ -89,11 +89,6 @@ where
}
/// Returns a mutable pointer to the inner value.
///
/// # Safety
///
/// This is unsafe since it allows to mutably borrow the inner value through
/// a shared reference. The same rules apply here as with [`UnsafeCell::get`].
pub fn get_ptr(&self) -> NonNull<T> {
// SAFETY: The inner `T` of the internal `UnsafeCell` exists and thus
// the pointer that we get returned to it via `UnsafeCell::get`
......
......@@ -23,10 +23,8 @@ pub mod traits;
#[doc(inline)]
pub use self::{
collections::{
Box,
Vec,
},
alloc::Box,
collections::Vec,
lazy::Lazy,
memory::Memory,
pack::Pack,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment