Tweak spawn table creation to not overflow.
This commit is contained in:
parent
62ed38c952
commit
ffa783bff1
|
@ -522,9 +522,11 @@ impl<T> RandomTable<T>
|
||||||
where
|
where
|
||||||
T: Clone,
|
T: Clone,
|
||||||
{
|
{
|
||||||
pub fn add(&mut self, value: T, weight: u32) -> &mut Self {
|
pub fn add(&mut self, value: T, weight: i32) -> &mut Self {
|
||||||
for _ in 0..weight {
|
if weight > 0 {
|
||||||
self.0.push(value.clone());
|
for _ in 0..weight {
|
||||||
|
self.0.push(value.clone());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user