File tree 2 files changed +6
-5
lines changed
2 files changed +6
-5
lines changed Original file line number Diff line number Diff line change 1
1
//! Free functions to create `&[T]` and `&mut [T]`.
2
2
3
3
use crate :: array;
4
- use crate :: intrinsics:: is_aligned_and_not_null;
5
- use crate :: mem;
6
4
use crate :: ops:: Range ;
7
5
use crate :: ptr;
8
6
@@ -195,7 +193,8 @@ pub const fn from_mut<T>(s: &mut T) -> &mut [T] {
195
193
/// to the first element of a slice.
196
194
///
197
195
/// * The `end` pointer must be a [valid] and properly aligned pointer to *one past*
198
- /// the last element.
196
+ /// the last element, such that the offset from the end to the start pointer is
197
+ /// the length of the slice.
199
198
///
200
199
/// * The range must contain `N` consecutive properly initialized values of type `T`:
201
200
///
@@ -251,7 +250,8 @@ pub unsafe fn from_ptr_range<'a, T>(range: Range<*const T>) -> &'a [T] {
251
250
/// to the first element of a slice.
252
251
///
253
252
/// * The `end` pointer must be a [valid] and properly aligned pointer to *one past*
254
- /// the last element.
253
+ /// the last element, such that the offset from the end to the start pointer is
254
+ /// the length of the slice.
255
255
///
256
256
/// * The range must contain `N` consecutive properly initialized values of type `T`:
257
257
///
@@ -274,7 +274,7 @@ pub unsafe fn from_ptr_range<'a, T>(range: Range<*const T>) -> &'a [T] {
274
274
///
275
275
/// use core::slice;
276
276
///
277
- /// let x = [1, 2, 3];
277
+ /// let mut x = [1, 2, 3];
278
278
/// let range = x.as_mut_ptr_range();
279
279
///
280
280
/// unsafe {
Original file line number Diff line number Diff line change @@ -2234,6 +2234,7 @@ fn slice_split_array_mut_out_of_bounds() {
2234
2234
v. split_array_mut :: < 7 > ( ) ;
2235
2235
}
2236
2236
2237
+ #[ test]
2237
2238
fn test_slice_from_ptr_range ( ) {
2238
2239
let arr = [ "foo" . to_owned ( ) , "bar" . to_owned ( ) ] ;
2239
2240
let range = arr. as_ptr_range ( ) ;
You can’t perform that action at this time.
0 commit comments