Skip to content

Commit 6d1d432

Browse files
committed
naming consistency
1 parent 0b355e2 commit 6d1d432

File tree

4 files changed

+17
-17
lines changed

4 files changed

+17
-17
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "memapi2"
3-
version = "0.5.0"
3+
version = "0.5.1"
44
edition = "2018"
55
rust-version = "1.56.0"
66
authors = ["echohumm"]

build.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ mod checks {
5050
let ptr = slice.as_mut_ptr();
5151
let len = slice.len();
5252

53-
let slice_ptr = slice_ptr_from_raw_parts(ptr, len);
53+
let slice_ptr = slice_ptr_from_parts(ptr, len);
5454

5555
// check that they dereference to the same thing
5656
if unsafe { &*slice_ptr } != slice {
@@ -78,7 +78,7 @@ mod checks {
7878

7979
unsafe {
8080
if len
81-
!= nonnull_slice_len(nonnull_slice_from_raw_parts(
81+
!= nonnull_slice_len(nonnull_slice_from_parts(
8282
NonNull::new_unchecked(ptr),
8383
len
8484
))
@@ -123,12 +123,12 @@ mod checks {
123123
}
124124

125125
#[must_use]
126-
fn nonnull_slice_from_raw_parts<T>(p: NonNull<T>, len: usize) -> NonNull<[T]> {
127-
unsafe { NonNull::new_unchecked(slice_ptr_from_raw_parts(p.as_ptr(), len)) }
126+
fn nonnull_slice_from_parts<T>(p: NonNull<T>, len: usize) -> NonNull<[T]> {
127+
unsafe { NonNull::new_unchecked(slice_ptr_from_parts(p.as_ptr(), len)) }
128128
}
129129

130130
#[must_use]
131-
fn slice_ptr_from_raw_parts<T>(p: *mut T, len: usize) -> *mut [T] {
131+
fn slice_ptr_from_parts<T>(p: *mut T, len: usize) -> *mut [T] {
132132
unsafe {
133133
// i hate this so much
134134
*((&(p, len)) as *const (*mut T, usize)).cast::<*mut [T]>()

src/data/type_props.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ const_if! {
307307
#[must_use]
308308
pub const fn varsized_dangling_pointer<T: ?Sized + VarSized>() -> *mut T {
309309
// SAFETY: the implementor of VarSized guarantees the ALN is valid.
310-
varsized_pointer_from_raw_parts(unsafe { dangling_nonnull(T::ALN).as_ptr() }, 0)
310+
varsized_pointer_from_parts(unsafe { dangling_nonnull(T::ALN).as_ptr() }, 0)
311311
}
312312
}
313313

@@ -321,7 +321,7 @@ const_if! {
321321
meta: usize,
322322
) -> NonNull<T> {
323323
// SAFETY: `p` was already non-null, so it with different meta must also be nn.
324-
unsafe { NonNull::new_unchecked(varsized_pointer_from_raw_parts(p.as_ptr(), meta)) }
324+
unsafe { NonNull::new_unchecked(varsized_pointer_from_parts(p.as_ptr(), meta)) }
325325
}
326326
}
327327

@@ -331,7 +331,7 @@ const_if! {
331331
#[must_use]
332332
#[inline]
333333
#[allow(clippy::not_unsafe_ptr_arg_deref)]
334-
pub const fn varsized_pointer_from_raw_parts<T: ?Sized + VarSized>(
334+
pub const fn varsized_pointer_from_parts<T: ?Sized + VarSized>(
335335
p: *mut u8,
336336
meta: usize,
337337
) -> *mut T {

src/helpers.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use {
77
SizedProps,
88
USIZE_MAX_NO_HIGH_BIT,
99
varsized_nonnull_from_parts,
10-
varsized_pointer_from_raw_parts
10+
varsized_pointer_from_parts
1111
},
1212
error::{AlignErr, AllocError, ArithErr, ArithOp, Cause, InvLayout, LayoutErr}
1313
},
@@ -206,7 +206,7 @@ const_if! {
206206
"Creates a `NonNull<[T]>` from a pointer and a length.\n\nThis is a helper used in place of
207207
[`NonNull::slice_from_raw_parts`], which was stabilized after this crate's MSRV.",
208208
#[must_use]
209-
pub const fn nonnull_slice_from_raw_parts<T>(p: NonNull<T>, len: usize) -> NonNull<[T]> {
209+
pub const fn nonnull_slice_from_parts<T>(p: NonNull<T>, len: usize) -> NonNull<[T]> {
210210
varsized_nonnull_from_parts(p.cast(), len)
211211
}
212212
}
@@ -216,8 +216,8 @@ const_if! {
216216
"Creates a `*mut [T]` from a pointer and a length.\n\nThis is a helper used in place of \
217217
[`ptr::slice_from_raw_parts_mut`], which was const-stabilized after this crate's MSRV.",
218218
#[must_use]
219-
pub const fn slice_ptr_from_raw_parts<T>(p: *mut T, len: usize) -> *mut [T] {
220-
varsized_pointer_from_raw_parts(p.cast(), len)
219+
pub const fn slice_ptr_from_parts<T>(p: *mut T, len: usize) -> *mut [T] {
220+
varsized_pointer_from_parts(p.cast(), len)
221221
}
222222
}
223223

@@ -553,7 +553,7 @@ impl<'a, T, A: Alloc + ?Sized> SliceAllocGuard<'a, T, A> {
553553
#[cfg_attr(miri, track_caller)]
554554
#[must_use]
555555
pub const fn get_init_part(&self) -> NonNull<[T]> {
556-
nonnull_slice_from_raw_parts(self.ptr, self.init)
556+
nonnull_slice_from_parts(self.ptr, self.init)
557557
}
558558
}
559559

@@ -562,7 +562,7 @@ impl<'a, T, A: Alloc + ?Sized> SliceAllocGuard<'a, T, A> {
562562
"Gets a `NonNull<[T]>` pointer to the uninitialized elements of the slice.",
563563
#[must_use]
564564
pub const fn get_uninit_part(&self) -> NonNull<[T]> {
565-
nonnull_slice_from_raw_parts(
565+
nonnull_slice_from_parts(
566566
// SAFETY: the pointer was a valid NonNull to begin with, adding cannot invalidate
567567
// it. `self.init` will be in bounds unless an init-setting method was used
568568
// incorrectly.
@@ -578,7 +578,7 @@ impl<'a, T, A: Alloc + ?Sized> SliceAllocGuard<'a, T, A> {
578578
#[cfg_attr(miri, track_caller)]
579579
#[must_use]
580580
pub const fn get_full(&self) -> NonNull<[T]> {
581-
nonnull_slice_from_raw_parts(self.ptr, self.full)
581+
nonnull_slice_from_parts(self.ptr, self.full)
582582
}
583583
}
584584

@@ -755,7 +755,7 @@ impl<T, A: Alloc + ?Sized> Drop for SliceAllocGuard<'_, T, A> {
755755
// SAFETY: `self.init` will be correct without improper usage of methods which set it. new()
756756
// requires that the pointer was allocated using the provided allocator.
757757
unsafe {
758-
ptr::drop_in_place(slice_ptr_from_raw_parts(self.ptr.as_ptr(), self.init));
758+
ptr::drop_in_place(slice_ptr_from_parts(self.ptr.as_ptr(), self.init));
759759
self.alloc.dealloc(
760760
self.ptr.cast(),
761761
Layout::from_size_align_unchecked(T::SZ * self.full, T::ALN)

0 commit comments

Comments
 (0)