@@ -17,27 +17,15 @@ 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:
20
+ /// This allows to index the IndexVec with the new index type
21
21
///
22
- /// ```
23
- /// use crate as rustc_index;
24
- /// use rustc_index::{IndexVec, newtype_index};
25
- ///
26
- /// newtype_index! {
27
- /// pub struct MyIdx {}
28
- /// }
29
- ///
30
- /// let my_index_vec: IndexVec<MyIdx, u32> = IndexVec::from_raw(vec![0,1,2,3]);
31
- /// let idx: MyIdx = MyIdx::from_u32(2);
32
- /// assert_eq!(my_index_vec[idx], 2);
33
- /// ```
34
22
///
35
23
/// [`newtype_index!`]: ../macro.newtype_index.html
36
24
#[ derive( Clone , PartialEq , Eq , Hash ) ]
37
25
#[ repr( transparent) ]
38
26
pub struct IndexVec < I : Idx , T > {
39
27
pub raw : Vec < T > ,
40
- _marker : PhantomData < fn ( & I ) > ,
28
+ _marker : PhantomData < I > ,
41
29
}
42
30
43
31
impl < I : Idx , T > IndexVec < I , T > {
@@ -77,7 +65,7 @@ impl<I: Idx, T> IndexVec<I, T> {
77
65
IndexVec :: from_raw ( vec ! [ elem; universe. len( ) ] )
78
66
}
79
67
80
- /// Creates a new ` IndexVec` with n copies of `elem`
68
+ /// Creates a new IndexVec
81
69
#[ inline]
82
70
pub fn from_elem_n ( elem : T , n : usize ) -> Self
83
71
where
0 commit comments