18
18
use core:: fmt:: Write ;
19
19
20
20
use core:: ops:: { Index , IndexMut } ;
21
+ use core:: ptr:: NonNull ;
21
22
use core:: time:: Duration ;
22
23
use core:: { fmt, u8} ;
23
24
@@ -294,7 +295,7 @@ pub struct Inner<'this> {
294
295
295
296
queue : Box < [ QueueCharacter ] > ,
296
297
grid : Box < [ Character ] > ,
297
- map : Box < [ Option < * mut QueueCharacter > ] > ,
298
+ map : Box < [ Option < NonNull < QueueCharacter > > ] > ,
298
299
bg_canvas : Box < [ u32 ] > ,
299
300
300
301
queue_cursor : usize ,
@@ -496,13 +497,13 @@ impl<'a> Inner<'a> {
496
497
queue. x = x;
497
498
queue. y = y;
498
499
499
- self . map [ i] = Some ( queue as * mut _ ) ;
500
+ self . map [ i] = Some ( NonNull :: from ( queue) ) ;
500
501
}
501
502
502
503
let item = self . map [ i] ;
503
504
504
505
unsafe {
505
- ( * item. unwrap ( ) ) . char = * char;
506
+ item. unwrap ( ) . as_mut ( ) . char = * char;
506
507
}
507
508
}
508
509
@@ -529,7 +530,7 @@ impl<'a> Inner<'a> {
529
530
530
531
if self . map [ i] . is_some ( ) {
531
532
unsafe {
532
- char = ( * self . map [ i] . unwrap ( ) ) . char ;
533
+ char = self . map [ i] . unwrap ( ) . as_ref ( ) . char ;
533
534
}
534
535
} else {
535
536
char = self . grid [ i] ;
@@ -541,7 +542,7 @@ impl<'a> Inner<'a> {
541
542
542
543
if self . map [ i] . is_some ( ) {
543
544
unsafe {
544
- self . grid [ i] = ( * self . map [ i] . unwrap ( ) ) . char ;
545
+ self . grid [ i] = self . map [ i] . unwrap ( ) . as_ref ( ) . char ;
545
546
}
546
547
547
548
self . map [ i] = None ;
@@ -686,7 +687,7 @@ impl<'a> Inner<'a> {
686
687
687
688
if let Some ( char) = queue {
688
689
unsafe {
689
- res = ( * char) . char ;
690
+ res = char. as_ref ( ) . char ;
690
691
}
691
692
} else {
692
693
res = self . grid [ i] ;
@@ -740,7 +741,7 @@ impl<'this> DebugRendy<'this> {
740
741
741
742
let grid = mem:: alloc_boxed_buffer :: < Character > ( rows * cols) ;
742
743
let queue = mem:: alloc_boxed_buffer :: < QueueCharacter > ( rows * cols) ;
743
- let map = mem:: alloc_boxed_buffer :: < Option < * mut QueueCharacter > > ( rows * cols) ;
744
+ let map = mem:: alloc_boxed_buffer :: < Option < NonNull < QueueCharacter > > > ( rows * cols) ;
744
745
let bg_canvas = mem:: alloc_boxed_buffer :: < u32 > ( width * height) ;
745
746
746
747
let mut this = Self {
0 commit comments