mirror of
https://github.com/bevyengine/bevy
synced 2024-11-26 06:30:19 +00:00
add Res::clone
(#4109)
# Objective Make `Res` cloneable ## Solution Add an associated fn `clone(self: &Self) -. Self` instead of `Copy + Clone` trait impls to avoid `res.clone()` failing to clone out the underlying `T`
This commit is contained in:
parent
263ab9424d
commit
92c90a9bad
1 changed files with 11 additions and 0 deletions
|
@ -291,6 +291,17 @@ where
|
|||
}
|
||||
|
||||
impl<'w, T: Resource> Res<'w, T> {
|
||||
// no it shouldn't clippy
|
||||
#[allow(clippy::should_implement_trait)]
|
||||
pub fn clone(this: &Self) -> Self {
|
||||
Self {
|
||||
value: this.value,
|
||||
ticks: this.ticks,
|
||||
last_change_tick: this.last_change_tick,
|
||||
change_tick: this.change_tick,
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns `true` if the resource was added after the system last ran.
|
||||
pub fn is_added(&self) -> bool {
|
||||
self.ticks.is_added(self.last_change_tick, self.change_tick)
|
||||
|
|
Loading…
Reference in a new issue