1 use libc::c_int; 2 use std::marker::PhantomData; 3 4 /// A slot in a type's "extra data" structure. 5 /// 6 /// It is parameterized over the type containing the extra data as well as the 7 /// type of the data in the slot. 8 pub struct Index<T, U>(c_int, PhantomData<(T, U)>); 9 10 impl<T, U> Copy for Index<T, U> {} 11 12 impl<T, U> Clone for Index<T, U> { 13 fn clone(&self) -> Index<T, U> { 14 *self 15 } 16 } 17 18 impl<T, U> Index<T, U> { 19 pub unsafe fn from_raw(idx: c_int) -> Index<T, U> { 20 Index(idx, PhantomData) 21 } 22 23 pub fn as_raw(&self) -> c_int { 24 self.0 25 } 26 } 27