From 1d54c5c911fd1e502b9d25e71ac4ce08b768ab8b Mon Sep 17 00:00:00 2001 From: Jakob Hellermann Date: Tue, 16 Mar 2021 18:13:57 +0100 Subject: [PATCH 1/5] fix 'attempted to subtract with overflow' for State::inactives --- crates/bevy_ecs/src/schedule/state.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/crates/bevy_ecs/src/schedule/state.rs b/crates/bevy_ecs/src/schedule/state.rs index f30592b55b561..c4e3bae6fdd28 100644 --- a/crates/bevy_ecs/src/schedule/state.rs +++ b/crates/bevy_ecs/src/schedule/state.rs @@ -378,7 +378,11 @@ where } pub fn inactives(&self) -> &[T] { - &self.stack[0..self.stack.len() - 2] + if let Some(idx) = self.stack.len().checked_sub(2) { + &self.stack[0..idx] + } else { + &[] + } } } From eace6cb24afad858a2a48cb345446d9798a2074d Mon Sep 17 00:00:00 2001 From: Jakob Hellermann Date: Tue, 16 Mar 2021 18:54:57 +0100 Subject: [PATCH 2/5] Update crates/bevy_ecs/src/schedule/state.rs Co-authored-by: bjorn3 --- crates/bevy_ecs/src/schedule/state.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/crates/bevy_ecs/src/schedule/state.rs b/crates/bevy_ecs/src/schedule/state.rs index c4e3bae6fdd28..f5f3378d50604 100644 --- a/crates/bevy_ecs/src/schedule/state.rs +++ b/crates/bevy_ecs/src/schedule/state.rs @@ -378,11 +378,7 @@ where } pub fn inactives(&self) -> &[T] { - if let Some(idx) = self.stack.len().checked_sub(2) { - &self.stack[0..idx] - } else { - &[] - } + self.stack.split_last().map(|(_last, rest)| rest).unwrap_or(&[]) } } From 286307ade2286b25e56c24e1d0bdbed289ac718d Mon Sep 17 00:00:00 2001 From: Jakob Hellermann Date: Tue, 16 Mar 2021 19:35:42 +0100 Subject: [PATCH 3/5] review comment --- crates/bevy_ecs/src/schedule/state.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/bevy_ecs/src/schedule/state.rs b/crates/bevy_ecs/src/schedule/state.rs index f5f3378d50604..0a77530fb9897 100644 --- a/crates/bevy_ecs/src/schedule/state.rs +++ b/crates/bevy_ecs/src/schedule/state.rs @@ -378,7 +378,10 @@ where } pub fn inactives(&self) -> &[T] { - self.stack.split_last().map(|(_last, rest)| rest).unwrap_or(&[]) + self.stack + .split_last() + .map(|(_last, rest)| rest) + .unwrap() } } From 5172d9ce596542c7538cd5bd2972a194339b009a Mon Sep 17 00:00:00 2001 From: Jakob Hellermann Date: Wed, 17 Mar 2021 13:02:20 +0100 Subject: [PATCH 4/5] fmt again --- crates/bevy_ecs/src/schedule/state.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/crates/bevy_ecs/src/schedule/state.rs b/crates/bevy_ecs/src/schedule/state.rs index 0a77530fb9897..eace761c7340c 100644 --- a/crates/bevy_ecs/src/schedule/state.rs +++ b/crates/bevy_ecs/src/schedule/state.rs @@ -378,10 +378,7 @@ where } pub fn inactives(&self) -> &[T] { - self.stack - .split_last() - .map(|(_last, rest)| rest) - .unwrap() + self.stack.split_last().map(|(_last, rest)| rest).unwrap() } } From 99bea0d6b88b88c6e7fc36ab6e2cbc0a778abfef Mon Sep 17 00:00:00 2001 From: Jakob Hellermann Date: Sat, 10 Apr 2021 13:30:15 +0200 Subject: [PATCH 5/5] Update crates/bevy_ecs/src/schedule/state.rs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Alexander Krivács Schrøder --- crates/bevy_ecs/src/schedule/state.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/bevy_ecs/src/schedule/state.rs b/crates/bevy_ecs/src/schedule/state.rs index eace761c7340c..e7b663db8db64 100644 --- a/crates/bevy_ecs/src/schedule/state.rs +++ b/crates/bevy_ecs/src/schedule/state.rs @@ -378,7 +378,7 @@ where } pub fn inactives(&self) -> &[T] { - self.stack.split_last().map(|(_last, rest)| rest).unwrap() + self.stack.split_last().map(|(_, rest)| rest).unwrap() } }