1
1
use crate :: {
2
2
access:: { ReadOnly , ReadWrite , WriteOnly } ,
3
- map_field_mut , VolatilePtr ,
3
+ map_field , VolatilePtr ,
4
4
} ;
5
5
use core:: ptr:: NonNull ;
6
6
@@ -66,11 +66,11 @@ fn test_struct() {
66
66
} ;
67
67
let volatile = unsafe { VolatilePtr :: new ( NonNull :: from ( & mut val) ) } ;
68
68
unsafe {
69
- volatile. map_mut ( |s| NonNull :: new ( core:: ptr:: addr_of_mut!( ( * s. as_ptr( ) ) . field_1) ) . unwrap ( ) )
69
+ volatile. map ( |s| NonNull :: new ( core:: ptr:: addr_of_mut!( ( * s. as_ptr( ) ) . field_1) ) . unwrap ( ) )
70
70
}
71
71
. update ( |v| v + 1 ) ;
72
72
let field_2 = unsafe {
73
- volatile. map_mut ( |s| NonNull :: new ( core:: ptr:: addr_of_mut!( ( * s. as_ptr( ) ) . field_2) ) . unwrap ( ) )
73
+ volatile. map ( |s| NonNull :: new ( core:: ptr:: addr_of_mut!( ( * s. as_ptr( ) ) . field_2) ) . unwrap ( ) )
74
74
} ;
75
75
assert ! ( field_2. read( ) ) ;
76
76
field_2. write ( false ) ;
@@ -96,9 +96,9 @@ fn test_struct_macro() {
96
96
field_2 : true ,
97
97
} ;
98
98
let volatile = unsafe { VolatilePtr :: new ( NonNull :: from ( & mut val) ) } ;
99
- let field_1 = map_field_mut ! ( volatile. field_1) ;
99
+ let field_1 = map_field ! ( volatile. field_1) ;
100
100
field_1. update ( |v| v + 1 ) ;
101
- let field_2 = map_field_mut ! ( volatile. field_2) ;
101
+ let field_2 = map_field ! ( volatile. field_2) ;
102
102
assert ! ( field_2. read( ) ) ;
103
103
field_2. write ( false ) ;
104
104
assert_eq ! (
@@ -115,7 +115,7 @@ fn test_struct_macro() {
115
115
fn test_slice ( ) {
116
116
let val: & mut [ u32 ] = & mut [ 1 , 2 , 3 ] ;
117
117
let volatile = unsafe { VolatilePtr :: new ( NonNull :: from ( val) ) } ;
118
- volatile. index_mut ( 0 ) . update ( |v| v + 1 ) ;
118
+ volatile. index ( 0 ) . update ( |v| v + 1 ) ;
119
119
120
120
let mut dst = [ 0 ; 3 ] ;
121
121
volatile. copy_into_slice ( & mut dst) ;
@@ -128,7 +128,7 @@ fn test_slice() {
128
128
fn test_bounds_check_1 ( ) {
129
129
let val: & mut [ u32 ] = & mut [ 1 , 2 , 3 ] ;
130
130
let volatile = unsafe { VolatilePtr :: new ( NonNull :: from ( val) ) } ;
131
- volatile. index_mut ( 3 ) ;
131
+ volatile. index ( 3 ) ;
132
132
}
133
133
134
134
#[ cfg( feature = "unstable" ) ]
@@ -137,7 +137,7 @@ fn test_bounds_check_1() {
137
137
fn test_bounds_check_2 ( ) {
138
138
let val: & mut [ u32 ] = & mut [ 1 , 2 , 3 ] ;
139
139
let volatile = unsafe { VolatilePtr :: new ( NonNull :: from ( val) ) } ;
140
- volatile. index_mut ( 2 ..1 ) ;
140
+ volatile. index ( 2 ..1 ) ;
141
141
}
142
142
143
143
#[ cfg( feature = "unstable" ) ]
@@ -146,15 +146,15 @@ fn test_bounds_check_2() {
146
146
fn test_bounds_check_3 ( ) {
147
147
let val: & mut [ u32 ] = & mut [ 1 , 2 , 3 ] ;
148
148
let volatile = unsafe { VolatilePtr :: new ( NonNull :: from ( val) ) } ;
149
- volatile. index_mut ( 4 ..) ; // `3..` is is still ok (see next test)
149
+ volatile. index ( 4 ..) ; // `3..` is is still ok (see next test)
150
150
}
151
151
152
152
#[ cfg( feature = "unstable" ) ]
153
153
#[ test]
154
154
fn test_bounds_check_4 ( ) {
155
155
let val: & mut [ u32 ] = & mut [ 1 , 2 , 3 ] ;
156
156
let volatile = unsafe { VolatilePtr :: new ( NonNull :: from ( val) ) } ;
157
- assert_eq ! ( volatile. index_mut ( 3 ..) . len( ) , 0 ) ;
157
+ assert_eq ! ( volatile. index ( 3 ..) . len( ) , 0 ) ;
158
158
}
159
159
160
160
#[ cfg( feature = "unstable" ) ]
@@ -163,16 +163,16 @@ fn test_bounds_check_4() {
163
163
fn test_bounds_check_5 ( ) {
164
164
let val: & mut [ u32 ] = & mut [ 1 , 2 , 3 ] ;
165
165
let volatile = unsafe { VolatilePtr :: new ( NonNull :: from ( val) ) } ;
166
- volatile. index_mut ( ..4 ) ;
166
+ volatile. index ( ..4 ) ;
167
167
}
168
168
169
169
#[ cfg( feature = "unstable" ) ]
170
170
#[ test]
171
171
fn test_chunks ( ) {
172
172
let val: & mut [ u32 ] = & mut [ 1 , 2 , 3 , 4 , 5 , 6 ] ;
173
173
let volatile = unsafe { VolatilePtr :: new ( NonNull :: from ( val) ) } ;
174
- let chunks = volatile. as_chunks_mut ( ) . 0 ;
175
- chunks. index_mut ( 1 ) . write ( [ 10 , 11 , 12 ] ) ;
174
+ let chunks = volatile. as_chunks ( ) . 0 ;
175
+ chunks. index ( 1 ) . write ( [ 10 , 11 , 12 ] ) ;
176
176
assert_eq ! ( chunks. index( 0 ) . read( ) , [ 1 , 2 , 3 ] ) ;
177
177
assert_eq ! ( chunks. index( 1 ) . read( ) , [ 10 , 11 , 12 ] ) ;
178
178
}
0 commit comments