pub fn add_stage_before<S: Stage>(
        &mut self,
        target: impl StageLabel,
        label: impl StageLabel,
        stage: S,
    ) -> &mut Self {
        let label: Box<dyn StageLabel> = Box::new(label);
        let target = &target as &dyn StageLabel;
        let target_index = self
            .stage_order
            .iter()
            .enumerate()
            .find(|(_i, stage_label)| &***stage_label == target)
            .map(|(i, _)| i)
            .unwrap_or_else(|| panic!("Target stage does not exist: {:?}.", target));

        self.stage_order.insert(target_index, label.clone());
        let prev = self.stages.insert(label.clone(), Box::new(stage));
        if prev.is_some() {
            panic!("Stage already exists: {:?}.", label);
        }
        self
    }
/// Adds the given `stage` immediately before the `target` stage.
///
/// # Example
///
/// ```
/// # use bevy_ecs::prelude::*;
/// #
/// # let mut schedule = Schedule::default();
/// # schedule.add_stage("target_stage", SystemStage::parallel());
/// #
/// schedule.add_stage_before("target_stage", "my_stage", SystemStage::parallel());
Adds the given `stage` immediately before the `target` stage.
Adds the given ` stage ` immediately before the ` target ` stage .
pub fn add_stage_before<S: Stage>(
        &mut self,
        target: impl StageLabel,
        label: impl StageLabel,
        stage: S,
    ) -> &mut Self {
        let label: Box<dyn StageLabel> = Box::new(label);
        let target = &target as &dyn StageLabel;
        let target_index = self
            .stage_order
            .iter()
            .enumerate()
            .find(|(_i, stage_label)| &***stage_label == target)
            .map(|(i, _)| i)
            .unwrap_or_else(|| panic!("Target stage does not exist: {:?}.", target));
        self.stage_order.insert(target_index, label.clone());
        let prev = self.stages.insert(label.clone(), Box::new(stage));
        if prev.is_some() {
            panic!("Stage already exists: {:?}.", label);
        }
        self
    }
pub fn add_stage_before < S : Stage > ( & mut self , target : impl StageLabel , label : impl StageLabel , stage : S , ) -> & mut Self { let label : Box < dyn StageLabel > = Box :: new ( label ) ; let target = & target as & dyn StageLabel ; let target_index = self . stage_order . iter ( ) . enumerate ( ) . find ( | ( _i , stage_label ) | & * * * stage_label == target ) . map ( | ( i , _ ) | i ) . unwrap_or_else ( | | panic ! ( " " target ) ) ; self . stage_order . insert ( target_index , label . clone ( ) ) ; let prev = self . stages . insert ( label . clone ( ) , Box :: new ( stage ) ) ; if prev . is_some ( ) { panic ! ( " " label ) ; } self }
Adds the given `stage` immediately before the `target` stage.
Adds the given ` stage ` immediately before the ` target ` stage .
&mut self
target
impl StageLabel
label
impl StageLabel
stage
S
&mut self
target
impl StageLabel
label
impl StageLabel
stage
S
example
None
use bevy_ecs::prelude::*;
None
let mut schedule = schedule::default();
None
schedule.add_stage("target_stage", systemstage::parallel());
schedule.add_stage_before("target_stage", "my_stage", SystemStage::parallel()).
schedule . add_stage_before ( " target_stage " " my_stage " SystemStage :: parallel () ) .