@@ -17,15 +17,13 @@ use crate::{Idx, IndexSlice};
17
17
/// While it's possible to use `u32` or `usize` directly for `I`,
18
18
/// you almost certainly want to use a [`newtype_index!`]-generated type instead.
19
19
///
20
- /// This allows to index the IndexVec with the new index type
21
- ///
22
- ///
20
+ /// This allows to index the IndexVec with the new index type.
23
21
/// [`newtype_index!`]: ../macro.newtype_index.html
24
22
#[ derive( Clone , PartialEq , Eq , Hash ) ]
25
23
#[ repr( transparent) ]
26
24
pub struct IndexVec < I : Idx , T > {
27
25
pub raw : Vec < T > ,
28
- _marker : PhantomData < I > ,
26
+ _marker : PhantomData < fn ( & I ) > ,
29
27
}
30
28
31
29
impl < I : Idx , T > IndexVec < I , T > {
@@ -35,7 +33,7 @@ impl<I: Idx, T> IndexVec<I, T> {
35
33
IndexVec :: from_raw ( Vec :: new ( ) )
36
34
}
37
35
38
- /// Constructs a new `IndexVec<I, T>` from a `Vec<T>`
36
+ /// Constructs a new `IndexVec<I, T>` from a `Vec<T>`.
39
37
#[ inline]
40
38
pub const fn from_raw ( raw : Vec < T > ) -> Self {
41
39
IndexVec { raw, _marker : PhantomData }
@@ -65,7 +63,7 @@ impl<I: Idx, T> IndexVec<I, T> {
65
63
IndexVec :: from_raw ( vec ! [ elem; universe. len( ) ] )
66
64
}
67
65
68
- /// Creates a new IndexVec
66
+ /// Creates a new IndexVec with n copies of the `elem`.
69
67
#[ inline]
70
68
pub fn from_elem_n ( elem : T , n : usize ) -> Self
71
69
where
@@ -92,6 +90,7 @@ impl<I: Idx, T> IndexVec<I, T> {
92
90
IndexSlice :: from_raw_mut ( & mut self . raw )
93
91
}
94
92
93
+ /// Pushes an element to the array returning the index where it was pushed to.
95
94
#[ inline]
96
95
pub fn push ( & mut self , d : T ) -> I {
97
96
let idx = self . next_index ( ) ;
0 commit comments