Skip to content

Commit 43b1808

Browse files
author
root
committed
Mostly pointer type and style nitpicks
1 parent dab508a commit 43b1808

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/lib.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ extern crate quickcheck;
2121
/// You can use `array_ref` to generate an array reference to a subset
2222
/// of a sliceable bit of data (which could be an array, or a slice,
2323
/// or a Vec).
24+
///
25+
/// **Panics** if the slice is out of bounds.
2426
#[macro_export]
2527
macro_rules! array_ref {
2628
($arr:expr, $offset:expr, $len:expr) => {{
@@ -29,7 +31,7 @@ macro_rules! array_ref {
2931
unsafe fn as_array<T>(slice: &[T]) -> &[T; $len] {
3032
&*(slice.as_ptr() as *const [_; $len])
3133
}
32-
let slice = & $arr[$offset..$offset+$len];
34+
let slice = & $arr[$offset..$offset + $len];
3335
unsafe {
3436
as_array(slice)
3537
}
@@ -47,7 +49,7 @@ macro_rules! array_refs {
4749
#[inline]
4850
#[allow(unused_assignments)]
4951
unsafe fn as_arrays<T>(a: &[T; $( $len + )* 0 ]) -> ( $( &[T; $len], )* ) {
50-
let mut p = a.as_ptr() as *const T;
52+
let mut p = a.as_ptr();
5153
( $( {
5254
let aref = &*(p as *const [T; $len]);
5355
p = p.offset($len);
@@ -73,8 +75,8 @@ macro_rules! mut_array_refs {
7375
{
7476
#[inline]
7577
#[allow(unused_assignments)]
76-
unsafe fn as_arrays<T>(a: &mut[T; $( $len + )* 0 ]) -> ( $( &mut[T; $len], )* ) {
77-
let mut p = a.as_ptr() as *mut T;
78+
unsafe fn as_arrays<T>(a: &mut [T; $( $len + )* 0 ]) -> ( $( &mut [T; $len], )* ) {
79+
let mut p = a.as_mut_ptr();
7880
( $( {
7981
let aref = &mut *(p as *mut [T; $len]);
8082
p = p.offset($len);
@@ -92,15 +94,17 @@ macro_rules! mut_array_refs {
9294
/// You can use `array_mut_ref` to generate a mutable array reference
9395
/// to a subset of a sliceable bit of data (which could be an array,
9496
/// or a slice, or a Vec).
97+
///
98+
/// **Panics** if the slice is out of bounds.
9599
#[macro_export]
96100
macro_rules! array_mut_ref {
97101
($arr:expr, $offset:expr, $len:expr) => {{
98102
{
99103
#[inline]
100-
unsafe fn as_array<T>(slice: &mut[T]) -> &mut[T; $len] {
104+
unsafe fn as_array<T>(slice: &mut [T]) -> &mut [T; $len] {
101105
&mut *(slice.as_mut_ptr() as *mut [_; $len])
102106
}
103-
let slice = &mut $arr[$offset..$offset+$len];
107+
let slice = &mut $arr[$offset..$offset + $len];
104108
unsafe {
105109
as_array(slice)
106110
}

0 commit comments

Comments
 (0)