@@ -107,41 +107,6 @@ impl<'w> EntityRef<'w> {
107
107
. map ( |ticks| ticks. deref ( ) )
108
108
}
109
109
}
110
-
111
- /// Gets a mutable reference to the component of type `T` associated with
112
- /// this entity without ensuring there are no other borrows active and without
113
- /// ensuring that the returned reference will stay valid.
114
- ///
115
- /// # Safety
116
- ///
117
- /// - The returned reference must never alias a mutable borrow of this component.
118
- /// - The returned reference must not be used after this component is moved which
119
- /// may happen from **any** `insert_component`, `remove_component` or `despawn`
120
- /// operation on this world (non-exhaustive list).
121
- #[ inline]
122
- pub unsafe fn get_unchecked_mut < T : Component > (
123
- & self ,
124
- last_change_tick : u32 ,
125
- change_tick : u32 ,
126
- ) -> Option < Mut < ' w , T > > {
127
- self . world
128
- . storages
129
- . get_component_and_ticks_with_type (
130
- & self . world . archetypes ,
131
- & self . world . components ,
132
- TypeId :: of :: < T > ( ) ,
133
- self . entity ,
134
- self . location ,
135
- )
136
- . map ( |( value, ticks) | Mut {
137
- value : value. assert_unique ( ) . deref_mut :: < T > ( ) ,
138
- ticks : Ticks {
139
- component_ticks : ticks. deref_mut ( ) ,
140
- last_change_tick,
141
- change_tick,
142
- } ,
143
- } )
144
- }
145
110
}
146
111
147
112
impl < ' w > EntityRef < ' w > {
@@ -253,7 +218,25 @@ impl<'w> EntityMut<'w> {
253
218
#[ inline]
254
219
pub fn get_mut < T : Component > ( & mut self ) -> Option < Mut < ' _ , T > > {
255
220
// SAFETY: world access is unique, and lifetimes enforce correct usage of returned borrow
256
- unsafe { self . get_unchecked_mut :: < T > ( ) }
221
+ unsafe {
222
+ self . world
223
+ . storages
224
+ . get_component_and_ticks_with_type (
225
+ & self . world . archetypes ,
226
+ & self . world . components ,
227
+ TypeId :: of :: < T > ( ) ,
228
+ self . entity ,
229
+ self . location ,
230
+ )
231
+ . map ( |( value, ticks) | Mut {
232
+ value : value. assert_unique ( ) . deref_mut :: < T > ( ) ,
233
+ ticks : Ticks {
234
+ component_ticks : ticks. deref_mut ( ) ,
235
+ last_change_tick : self . world . last_change_tick ( ) ,
236
+ change_tick : self . world . read_change_tick ( ) ,
237
+ } ,
238
+ } )
239
+ }
257
240
}
258
241
259
242
/// Retrieves the change ticks for the given component. This can be useful for implementing change
@@ -279,37 +262,6 @@ impl<'w> EntityMut<'w> {
279
262
}
280
263
}
281
264
282
- /// Gets a mutable reference to the component of type `T` associated with
283
- /// this entity without ensuring there are no other borrows active and without
284
- /// ensuring that the returned reference will stay valid.
285
- ///
286
- /// # Safety
287
- ///
288
- /// - The returned reference must never alias a mutable borrow of this component.
289
- /// - The returned reference must not be used after this component is moved which
290
- /// may happen from **any** `insert_component`, `remove_component` or `despawn`
291
- /// operation on this world (non-exhaustive list).
292
- #[ inline]
293
- pub unsafe fn get_unchecked_mut < T : Component > ( & self ) -> Option < Mut < ' _ , T > > {
294
- self . world
295
- . storages
296
- . get_component_and_ticks_with_type (
297
- & self . world . archetypes ,
298
- & self . world . components ,
299
- TypeId :: of :: < T > ( ) ,
300
- self . entity ,
301
- self . location ,
302
- )
303
- . map ( |( value, ticks) | Mut {
304
- value : value. assert_unique ( ) . deref_mut :: < T > ( ) ,
305
- ticks : Ticks {
306
- component_ticks : ticks. deref_mut ( ) ,
307
- last_change_tick : self . world . last_change_tick ( ) ,
308
- change_tick : self . world . read_change_tick ( ) ,
309
- } ,
310
- } )
311
- }
312
-
313
265
#[ deprecated(
314
266
since = "0.9.0" ,
315
267
note = "Use `insert` instead, which now accepts bundles, components, and tuples of bundles and components."
0 commit comments