File tree Expand file tree Collapse file tree 3 files changed +8
-23
lines changed Expand file tree Collapse file tree 3 files changed +8
-23
lines changed Original file line number Diff line number Diff line change @@ -20,30 +20,15 @@ pub unsafe trait Array {
20
20
type Index : Index ;
21
21
/// The array's element capacity
22
22
const CAPACITY : usize ;
23
- #[ doc( hidden) ]
24
- fn as_ptr ( & self ) -> * const Self :: Item ;
25
- #[ doc( hidden) ]
26
- fn capacity ( ) -> usize ;
23
+ fn as_slice ( & self ) -> & [ Self :: Item ] ;
24
+ fn as_mut_slice ( & mut self ) -> & mut [ Self :: Item ] ;
27
25
}
28
26
29
27
pub trait Index : PartialEq + Copy {
30
28
fn to_usize ( self ) -> usize ;
31
29
fn from ( usize ) -> Self ;
32
30
}
33
31
34
- use std:: slice:: { from_raw_parts} ;
35
-
36
- pub trait ArrayExt : Array {
37
- #[ inline( always) ]
38
- fn as_slice ( & self ) -> & [ Self :: Item ] {
39
- unsafe {
40
- from_raw_parts ( self . as_ptr ( ) , Self :: capacity ( ) )
41
- }
42
- }
43
- }
44
-
45
- impl < A > ArrayExt for A where A : Array { }
46
-
47
32
impl Index for ( ) {
48
33
#[ inline( always) ]
49
34
fn to_usize ( self ) -> usize { 0 }
@@ -93,11 +78,11 @@ macro_rules! fix_array_impl {
93
78
type Index = $index_type;
94
79
const CAPACITY : usize = $len;
95
80
#[ doc( hidden) ]
96
- #[ inline( always ) ]
97
- fn as_ptr ( & self ) -> * const T { self as * const _ as * const _ }
81
+ #[ inline]
82
+ fn as_slice ( & self ) -> & [ Self :: Item ] { self }
98
83
#[ doc( hidden) ]
99
- #[ inline( always ) ]
100
- fn capacity ( ) -> usize { $len }
84
+ #[ inline]
85
+ fn as_mut_slice ( & mut self ) -> & mut [ Self :: Item ] { self }
101
86
}
102
87
)
103
88
}
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ use std::str::FromStr;
9
9
use std:: str:: Utf8Error ;
10
10
use std:: slice;
11
11
12
- use array:: { Array , ArrayExt } ;
12
+ use array:: Array ;
13
13
use array:: Index ;
14
14
use CapacityError ;
15
15
use char:: encode_utf8;
Original file line number Diff line number Diff line change @@ -155,7 +155,7 @@ impl<A: Array> ArrayVec<A> {
155
155
/// assert_eq!(array.capacity(), 3);
156
156
/// ```
157
157
#[ inline]
158
- pub fn capacity ( & self ) -> usize { A :: capacity ( ) }
158
+ pub fn capacity ( & self ) -> usize { A :: CAPACITY }
159
159
160
160
/// Return if the `ArrayVec` is completely filled.
161
161
///
You can’t perform that action at this time.
0 commit comments