1
- #![ cfg_attr( feature= "const_fn" , feature( const_fn) ) ]
1
+ #![ cfg_attr( feature = "const_fn" , feature( const_fn) ) ]
2
2
3
3
//! Provides wrapper types `Volatile`, `ReadOnly`, `WriteOnly`, `ReadWrite`, which wrap any copy-able type and allows for
4
4
//! volatile memory access to wrapped value. Volatile memory accesses are never optimized away by
@@ -50,7 +50,7 @@ impl<T: Copy> Volatile<T> {
50
50
/// # Panics
51
51
///
52
52
/// This method never panics.
53
- #[ cfg( feature= "const_fn" ) ]
53
+ #[ cfg( feature = "const_fn" ) ]
54
54
pub const fn new ( value : T ) -> Volatile < T > {
55
55
Volatile ( value)
56
56
}
@@ -66,7 +66,7 @@ impl<T: Copy> Volatile<T> {
66
66
/// # Panics
67
67
///
68
68
/// This method never panics.
69
- #[ cfg( not( feature= "const_fn" ) ) ]
69
+ #[ cfg( not( feature = "const_fn" ) ) ]
70
70
pub fn new ( value : T ) -> Volatile < T > {
71
71
Volatile ( value)
72
72
}
@@ -133,7 +133,8 @@ impl<T: Copy> Volatile<T> {
133
133
///
134
134
/// Ths method never panics.
135
135
pub fn update < F > ( & mut self , f : F )
136
- where F : FnOnce ( & mut T )
136
+ where
137
+ F : FnOnce ( & mut T ) ,
137
138
{
138
139
let mut value = self . read ( ) ;
139
140
f ( & mut value) ;
@@ -300,7 +301,9 @@ mod tests {
300
301
let volatile_ptr = target_ptr as * mut Volatile < u32 > ;
301
302
302
303
// UNSAFE: Safe, as we know the value exists on the stack.
303
- unsafe { ( * volatile_ptr) . write ( 42u32 ) ; }
304
+ unsafe {
305
+ ( * volatile_ptr) . write ( 42u32 ) ;
306
+ }
304
307
305
308
assert_eq ! ( target_value, 42u32 ) ;
306
309
}
0 commit comments