Skip to content
Snippets Groups Projects
Unverified Commit 63bad1fd authored by Kat Marchán's avatar Kat Marchán
Browse files

fix(scorers): Scorer builders now properly return themselves + some API changes

BREAKING CHANGE: All composite scorers now use push, instead of a weird push/when mixture. Additionally, they were previously (erroneously) returning &mut Self from push/when. This is now just Self, which means they will actually work now.
parent f871d19e
No related branches found
No related tags found
No related merge requests found
...@@ -112,7 +112,7 @@ impl StepsBuilder { ...@@ -112,7 +112,7 @@ impl StepsBuilder {
/** /**
Adds an action step. Order matters. Adds an action step. Order matters.
*/ */
pub fn step(&mut self, action_builder: impl ActionBuilder + 'static) -> &mut Self { pub fn step(mut self, action_builder: impl ActionBuilder + 'static) -> Self {
self.steps.push(Arc::new(action_builder)); self.steps.push(Arc::new(action_builder));
self self
} }
......
...@@ -165,7 +165,7 @@ pub mod prelude { ...@@ -165,7 +165,7 @@ pub mod prelude {
pub use super::BigBrainPlugin; pub use super::BigBrainPlugin;
pub use actions::{ActionBuilder, ActionState, Steps}; pub use actions::{ActionBuilder, ActionState, Steps};
pub use pickers::{FirstToScore, Picker}; pub use pickers::{FirstToScore, Picker};
pub use scorers::{AllOrNothing, FixedScore, Score, ScorerBuilder, SumOfScorers}; pub use scorers::{AllOrNothing, FixedScore, Score, ScorerBuilder, SumOfScorers, WinningScorer};
pub use thinker::{Actor, Thinker, ThinkerBuilder}; pub use thinker::{Actor, Thinker, ThinkerBuilder};
} }
......
...@@ -163,7 +163,7 @@ impl AllOrNothingBuilder { ...@@ -163,7 +163,7 @@ impl AllOrNothingBuilder {
/** /**
Add another Scorer to this [`ScorerBuilder`]. Add another Scorer to this [`ScorerBuilder`].
*/ */
pub fn push(&mut self, scorer: impl ScorerBuilder + 'static) -> &mut Self { pub fn push(mut self, scorer: impl ScorerBuilder + 'static) -> Self {
self.scorers.push(Arc::new(scorer)); self.scorers.push(Arc::new(scorer));
self self
} }
...@@ -245,7 +245,7 @@ pub struct SumOfScorersBuilder { ...@@ -245,7 +245,7 @@ pub struct SumOfScorersBuilder {
} }
impl SumOfScorersBuilder { impl SumOfScorersBuilder {
pub fn when(&mut self, scorer: impl ScorerBuilder + 'static) -> &mut Self { pub fn push(mut self, scorer: impl ScorerBuilder + 'static) -> Self {
self.scorers.push(Arc::new(scorer)); self.scorers.push(Arc::new(scorer));
self self
} }
...@@ -331,18 +331,11 @@ pub struct WinningScorerBuilder { ...@@ -331,18 +331,11 @@ pub struct WinningScorerBuilder {
scorers: Vec<Arc<dyn ScorerBuilder>>, scorers: Vec<Arc<dyn ScorerBuilder>>,
} }
impl WinningScorerBuilder {
pub fn when(&mut self, scorer: impl ScorerBuilder + 'static) -> &mut Self {
self.scorers.push(Arc::new(scorer));
self
}
}
impl WinningScorerBuilder { impl WinningScorerBuilder {
/** /**
Add another Scorer to this [`ScorerBuilder`]. Add another Scorer to this [`ScorerBuilder`].
*/ */
pub fn push(&mut self, scorer: impl ScorerBuilder + 'static) -> &mut Self { pub fn push(mut self, scorer: impl ScorerBuilder + 'static) -> Self {
self.scorers.push(Arc::new(scorer)); self.scorers.push(Arc::new(scorer));
self self
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment