Skip to content

Commit 92c90a9

Browse files
committed
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`
1 parent 263ab94 commit 92c90a9

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

crates/bevy_ecs/src/system/system_param.rs

+11
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,17 @@ where
291291
}
292292

293293
impl<'w, T: Resource> Res<'w, T> {
294+
// no it shouldn't clippy
295+
#[allow(clippy::should_implement_trait)]
296+
pub fn clone(this: &Self) -> Self {
297+
Self {
298+
value: this.value,
299+
ticks: this.ticks,
300+
last_change_tick: this.last_change_tick,
301+
change_tick: this.change_tick,
302+
}
303+
}
304+
294305
/// Returns `true` if the resource was added after the system last ran.
295306
pub fn is_added(&self) -> bool {
296307
self.ticks.is_added(self.last_change_tick, self.change_tick)

0 commit comments

Comments
 (0)