diff --git a/src/details.rs b/src/details.rs index feda2ce..c74e502 100644 --- a/src/details.rs +++ b/src/details.rs @@ -109,7 +109,7 @@ pub trait StorageDetails: ImplBase { type SizeType; /// The type representing result of storing data. - type StoreResult; + type PushResult; /// Builds a new internal state from provided parameters fn build_state( @@ -167,7 +167,7 @@ impl StorageDetails for ImplConcurrent { type Base = RwLock<*mut u8>; type AllocationTracker = Mutex; type SizeType = AtomicUsize; - type StoreResult = Result, LockingError>; + type PushResult = Result, LockingError>; fn build_state( base: *mut u8, @@ -261,7 +261,7 @@ impl StorageDetails for ImplDefault { type Base = Cell<*mut u8>; type AllocationTracker = RefCell; type SizeType = Cell; - type StoreResult = ContiguousEntryRef; + type PushResult = ContiguousEntryRef; fn build_state( base: *mut u8, @@ -354,7 +354,7 @@ impl StorageDetails for ImplUnsafe { type Base = *mut u8; type AllocationTracker = AllocationTracker; type SizeType = usize; - type StoreResult = Result<*mut T, ContiguousMemoryError>; + type PushResult = Result<*mut T, ContiguousMemoryError>; fn build_state( base: *mut u8, @@ -576,7 +576,7 @@ pub trait StoreDataDetails: StorageDetails { state: &mut Self::StorageState, data: *mut T, layout: Layout, - ) -> Self::StoreResult; + ) -> Self::PushResult; fn assume_stored( state: &Self::StorageState, diff --git a/src/lib.rs b/src/lib.rs index 8f96370..b2ebe41 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -184,15 +184,15 @@ impl ContiguousMemoryStorage { /// let mut storage = UnsafeContiguousMemory::new(0); /// let value = [2, 4, 8, 16]; /// - /// # assert_eq!(storage.can_store(&value).unwrap(), false); - /// if !storage.can_store(&value).unwrap() { + /// # assert_eq!(storage.can_push(&value).unwrap(), false); + /// if !storage.can_push(&value).unwrap() { /// storage.resize(storage.get_capacity() + size_of_val(&value)); /// /// // ...update old pointers... /// } /// /// let stored_value = - /// storage.store(value).expect("unable to store after growing the container"); + /// storage.push(value).expect("unable to store after growing the container"); /// ``` /// /// # Errors @@ -240,7 +240,7 @@ impl ContiguousMemoryStorage { /// Memory block can still be grown by calling [`ContiguousMemory::resize`], /// but it can't be done automatically as that would invalidate all the /// existing pointers without any indication. - pub fn push(&mut self, value: T) -> Impl::StoreResult { + pub fn push(&mut self, value: T) -> Impl::PushResult { let mut data = ManuallyDrop::new(value); let layout = Layout::for_value(&data); let pos = &mut *data as *mut T; @@ -259,7 +259,7 @@ impl ContiguousMemoryStorage { &mut self, data: *mut T, layout: Layout, - ) -> Impl::StoreResult { + ) -> Impl::PushResult { Impl::push_raw(&mut self.inner, data, layout) } @@ -275,7 +275,7 @@ impl ContiguousMemoryStorage { /// ```rust /// # use contiguous_mem::UnsafeContiguousMemory; /// let mut storage = UnsafeContiguousMemory::new(128); - /// let initial_position = storage.store(278u32).unwrap(); + /// let initial_position = storage.push(278u32).unwrap(); /// /// // ...other code... ///