Skip to content

Commit

Permalink
Rename StoreResult to PushResult.
Browse files Browse the repository at this point in the history
Update documentation examples

Signed-off-by: Tin Svagelj <[email protected]>
  • Loading branch information
Caellian committed Sep 15, 2023
1 parent 9779819 commit ea81008
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
10 changes: 5 additions & 5 deletions src/details.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ pub trait StorageDetails: ImplBase {
type SizeType;

/// The type representing result of storing data.
type StoreResult<T>;
type PushResult<T>;

/// Builds a new internal state from provided parameters
fn build_state(
Expand Down Expand Up @@ -167,7 +167,7 @@ impl StorageDetails for ImplConcurrent {
type Base = RwLock<*mut u8>;
type AllocationTracker = Mutex<AllocationTracker>;
type SizeType = AtomicUsize;
type StoreResult<T> = Result<Self::ReferenceType<T>, LockingError>;
type PushResult<T> = Result<Self::ReferenceType<T>, LockingError>;

fn build_state(
base: *mut u8,
Expand Down Expand Up @@ -261,7 +261,7 @@ impl StorageDetails for ImplDefault {
type Base = Cell<*mut u8>;
type AllocationTracker = RefCell<AllocationTracker>;
type SizeType = Cell<usize>;
type StoreResult<T> = ContiguousEntryRef<T>;
type PushResult<T> = ContiguousEntryRef<T>;

fn build_state(
base: *mut u8,
Expand Down Expand Up @@ -354,7 +354,7 @@ impl StorageDetails for ImplUnsafe {
type Base = *mut u8;
type AllocationTracker = AllocationTracker;
type SizeType = usize;
type StoreResult<T> = Result<*mut T, ContiguousMemoryError>;
type PushResult<T> = Result<*mut T, ContiguousMemoryError>;

fn build_state(
base: *mut u8,
Expand Down Expand Up @@ -576,7 +576,7 @@ pub trait StoreDataDetails: StorageDetails {
state: &mut Self::StorageState,
data: *mut T,
layout: Layout,
) -> Self::StoreResult<T>;
) -> Self::PushResult<T>;

fn assume_stored<T: StoreRequirements>(
state: &Self::StorageState,
Expand Down
12 changes: 6 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,15 +184,15 @@ impl<Impl: ImplDetails> ContiguousMemoryStorage<Impl> {
/// 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
Expand Down Expand Up @@ -240,7 +240,7 @@ impl<Impl: ImplDetails> ContiguousMemoryStorage<Impl> {
/// 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<T: StoreRequirements>(&mut self, value: T) -> Impl::StoreResult<T> {
pub fn push<T: StoreRequirements>(&mut self, value: T) -> Impl::PushResult<T> {
let mut data = ManuallyDrop::new(value);
let layout = Layout::for_value(&data);
let pos = &mut *data as *mut T;
Expand All @@ -259,7 +259,7 @@ impl<Impl: ImplDetails> ContiguousMemoryStorage<Impl> {
&mut self,
data: *mut T,
layout: Layout,
) -> Impl::StoreResult<T> {
) -> Impl::PushResult<T> {
Impl::push_raw(&mut self.inner, data, layout)
}

Expand All @@ -275,7 +275,7 @@ impl<Impl: ImplDetails> ContiguousMemoryStorage<Impl> {
/// ```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...
///
Expand Down

0 comments on commit ea81008

Please sign in to comment.