@@ -280,49 +280,3 @@ impl<FI> FieldReader<bool, FI> {
280
280
self . bit ( )
281
281
}
282
282
}
283
-
284
- /// Access an array of `COUNT` items of type `T` with the items `STRIDE` bytes
285
- /// apart. This is a zero-sized-type. No objects of this type are ever
286
- /// actually created, it is only a convenience for wrapping pointer arithmetic.
287
- ///
288
- /// There is no safe way to produce items of this type. Unsafe code can produce
289
- /// references by pointer casting. It is up to the unsafe code doing that, to
290
- /// ensure that the memory really is backed by appropriate content.
291
- ///
292
- /// Typically, this is used for accessing hardware registers.
293
- pub struct ArrayProxy < T , const COUNT : usize , const STRIDE : usize > {
294
- /// As well as providing a PhantomData, this field is non-public, and
295
- /// therefore ensures that code outside of this module can never create
296
- /// an ArrayProxy.
297
- _array : marker:: PhantomData < T >
298
- }
299
-
300
- impl < T , const C : usize , const S : usize > ArrayProxy < T , C , S > {
301
- /// Get a reference from an [ArrayProxy] with no bounds checking.
302
- pub unsafe fn get_ref ( & self , index : usize ) -> & T {
303
- let base = self as * const Self as usize ;
304
- let address = base + S * index;
305
- & * ( address as * const T )
306
- }
307
- /// Get a reference from an [ArrayProxy], or return `None` if the index
308
- /// is out of bounds.
309
- pub fn get ( & self , index : usize ) -> Option < & T > {
310
- if index < C {
311
- Some ( unsafe { self . get_ref ( index) } )
312
- }
313
- else {
314
- None
315
- }
316
- }
317
- /// Return the number of items.
318
- pub fn len ( & self ) -> usize { C }
319
- }
320
-
321
- impl < T , const C : usize , const S : usize > core:: ops:: Index < usize > for ArrayProxy < T , C , S > {
322
- type Output = T ;
323
- fn index ( & self , index : usize ) -> & T {
324
- // Do a real array dereference for the bounds check.
325
- [ ( ) ; C ] [ index] ;
326
- unsafe { self . get_ref ( index) }
327
- }
328
- }
0 commit comments