mirror of
https://github.com/bevyengine/bevy
synced 2024-11-10 07:04:33 +00:00
From implementations
This commit is contained in:
parent
b45d83ebda
commit
62081c66cd
1 changed files with 35 additions and 0 deletions
|
@ -587,6 +587,30 @@ impl<'w, T: Resource> From<ResMut<'w, T>> for Res<'w, T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'w, T: Resource> From<Ref<'w, T>> for Res<'w, T> {
|
||||
fn from(val: Ref<'w, T>) -> Self {
|
||||
Self {
|
||||
value: val.value,
|
||||
ticks: val.ticks,
|
||||
#[cfg(feature = "track_change_detection")]
|
||||
changed_by: val.changed_by,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'w, T: Resource> From<Res<'w, T>> for Ref<'w, T> {
|
||||
/// Convert a `Res` into a `Ref`. This allows keeping the change-detection feature of `Ref`
|
||||
/// while losing the specificity of `Res` for resources.
|
||||
fn from(res: Res<'w, T>) -> Self {
|
||||
Self {
|
||||
value: res.value,
|
||||
ticks: res.ticks,
|
||||
#[cfg(feature = "track_change_detection")]
|
||||
changed_by: res.changed_by,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'w, 'a, T: Resource> IntoIterator for &'a Res<'w, T>
|
||||
where
|
||||
&'a T: IntoIterator,
|
||||
|
@ -649,6 +673,17 @@ change_detection_mut_impl!(ResMut<'w, T>, T, Resource);
|
|||
impl_methods!(ResMut<'w, T>, T, Resource);
|
||||
impl_debug!(ResMut<'w, T>, Resource);
|
||||
|
||||
impl<'w, T: Resource> From<Mut<'w, T>> for ResMut<'w, T> {
|
||||
fn from(val: Mut<'w, T>) -> Self {
|
||||
Self {
|
||||
value: val.value,
|
||||
ticks: val.ticks,
|
||||
#[cfg(feature = "track_change_detection")]
|
||||
changed_by: val.changed_by,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'w, T: Resource> From<ResMut<'w, T>> for Mut<'w, T> {
|
||||
/// Convert this `ResMut` into a `Mut`. This allows keeping the change-detection feature of `Mut`
|
||||
/// while losing the specificity of `ResMut` for resources.
|
||||
|
|
Loading…
Reference in a new issue