File tree 1 file changed +10
-3
lines changed
1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -116,23 +116,30 @@ impl<'a> ByteAddressableBuffer<&'a mut [u32]> {
116
116
Self { data }
117
117
}
118
118
119
+ /// Create a non-mutable `ByteAddressableBuffer` from this mutable one.
120
+ #[ inline]
121
+ pub fn as_ref ( & self ) -> ByteAddressableBuffer < & [ u32 ] > {
122
+ ByteAddressableBuffer { data : self . data }
123
+ }
124
+
119
125
/// Loads an arbitrary type from the buffer. `byte_index` must be a
120
126
/// multiple of 4.
121
127
///
122
128
/// # Safety
123
129
/// See [`Self`].
130
+ #[ inline]
124
131
pub unsafe fn load < T > ( & self , byte_index : u32 ) -> T {
125
- bounds_check :: < T > ( self . data , byte_index) ;
126
- buffer_load_intrinsic ( self . data , byte_index)
132
+ self . as_ref ( ) . load ( byte_index)
127
133
}
128
134
129
135
/// Loads an arbitrary type from the buffer. `byte_index` must be a
130
136
/// multiple of 4.
131
137
///
132
138
/// # Safety
133
139
/// See [`Self`]. Additionally, bounds or alignment checking is not performed.
140
+ #[ inline]
134
141
pub unsafe fn load_unchecked < T > ( & self , byte_index : u32 ) -> T {
135
- buffer_load_intrinsic ( self . data , byte_index)
142
+ self . as_ref ( ) . load_unchecked ( byte_index)
136
143
}
137
144
138
145
/// Stores an arbitrary type into the buffer. `byte_index` must be a
You can’t perform that action at this time.
0 commit comments