Repository: bevyengine/bevy
File: crates/bevy_ecs/src/system/builder.rs (Rust)

Code before:
    /// Helper method for adding a [`Query`] as a param, equivalent to `of::<Query<D>>()`
    pub fn query<'w, 's, D: QueryData + 'static>() -> impl SystemParamBuilder<Query<'w, 's, D, ()>>
    {
        Self
    }

    /// Helper method for adding a filtered [`Query`] as a param, equivalent to `of::<Query<D, F>>()`
    pub fn query_filtered<'w, 's, D: QueryData + 'static, F: QueryFilter + 'static>(
    ) -> impl SystemParamBuilder<Query<'w, 's, D, F>> {
        Self
    }
}

/// A marker type used to distinguish builder systems from plain function systems.
#[doc(hidden)]
pub struct IsBuilderSystem;

/// An [`IntoSystem`] creating an instance of [`BuilderSystem`]
pub struct IntoBuilderSystem<Marker, In, Out, Func, Builder>
where
    Func: SystemParamFunction<Marker>,
    Builder: SystemParamBuilder<Func::Param>,
{
    builder: Builder,
    func: Func,
    _data: PhantomData<fn(In) -> (Marker, Out)>,
}

impl<Marker, In, Out, Func, Builder> IntoBuilderSystem<Marker, In, Out, Func, Builder>
where
    Func: SystemParamFunction<Marker>,
    Builder: SystemParamBuilder<Func::Param>,
{
    /// Returns a new [`IntoBuilderSystem`] given a system param builder and system function
    pub fn new(builder: Builder, func: Func) -> Self {
        Self {
            builder,
            func,
            _data: PhantomData,
        }
    }
}

impl<Marker, In, Out, Func, Builder> IntoSystem<In, Out, (IsBuilderSystem, Marker)>
    for IntoBuilderSystem<Marker, In, Out, Func, Builder>
where
    Marker: 'static,
    In: SystemInput + 'static,
    Out: 'static,
    Func: SystemParamFunction<Marker, In: FromInput<In>, Out: IntoResult<Out>>,
    Builder: SystemParamBuilder<Func::Param> + Send + Sync + 'static,

Review comment (suggestion):
Minor nit, but these seem to be called `marker` elsewhere.  

```suggestion
    _marker: PhantomData<fn(In) -> (Marker, Out)>,
```

Code after:

// SAFETY: Calls `SystemParam::init_state`
unsafe impl<P: SystemParam> SystemParamBuilder<P> for ParamBuilder {
    fn build(self, world: &mut World) -> P::State {
        P::init_state(world)
    }
}

impl ParamBuilder {
    /// Creates a [`SystemParamBuilder`] for any [`SystemParam`] that uses its default initialization.
    pub fn of<T: SystemParam>() -> impl SystemParamBuilder<T> {
        Self
    }

    /// Helper method for reading a [`Resource`] as a param, equivalent to `of::<Res<T>>()`
    pub fn resource<'w, T: Resource>() -> impl SystemParamBuilder<Res<'w, T>> {
        Self
    }

    /// Helper method for mutably accessing a [`Resource`] as a param, equivalent to `of::<ResMut<T>>()`
    pub fn resource_mut<'w, T: Resource>() -> impl SystemParamBuilder<ResMut<'w, T>> {
        Self
    }

    /// Helper method for adding a [`Local`] as a param, equivalent to `of::<Local<T>>()`
    pub fn local<'s, T: FromWorld + Send + 'static>() -> impl SystemParamBuilder<Local<'s, T>> {
        Self
    }

    /// Helper method for adding a [`Query`] as a param, equivalent to `of::<Query<D>>()`
    pub fn query<'w, 's, D: QueryData + 'static>() -> impl SystemParamBuilder<Query<'w, 's, D, ()>>
    {
        Self
    }

    /// Helper method for adding a filtered [`Query`] as a param, equivalent to `of::<Query<D, F>>()`
    pub fn query_filtered<'w, 's, D: QueryData + 'static, F: QueryFilter + 'static>(
    ) -> impl SystemParamBuilder<Query<'w, 's, D, F>> {
        Self
    }
}

/// A marker type used to distinguish builder systems from plain function systems.
#[doc(hidden)]
pub struct IsBuilderSystem;

/// An [`IntoSystem`] creating an instance of [`BuilderSystem`]
pub struct IntoBuilderSystem<Marker, In, Out, Func, Builder>
where
    Func: SystemParamFunction<Marker>,
    Builder: SystemParamBuilder<Func::Param>,