Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Merged by Bors] - Allow deriving SystemParam on private types #1936

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion crates/bevy_ecs/macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,13 +373,14 @@ pub fn derive_system_param(input: TokenStream) -> TokenStream {

let struct_name = &ast.ident;
let fetch_struct_name = Ident::new(&format!("{}State", struct_name), Span::call_site());
let fetch_struct_visibility = &ast.vis;

TokenStream::from(quote! {
impl #impl_generics #path::system::SystemParam for #struct_name#ty_generics #where_clause {
type Fetch = #fetch_struct_name <(#(<#field_types as SystemParam>::Fetch,)*), #punctuated_generic_idents>;
}

pub struct #fetch_struct_name<TSystemParamState, #punctuated_generic_idents> {
#fetch_struct_visibility struct #fetch_struct_name<TSystemParamState, #punctuated_generic_idents> {
state: TSystemParamState,
marker: std::marker::PhantomData<(#punctuated_generic_idents)>
}
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_ecs/src/system/system_param.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use std::{
/// use bevy_ecs::system::SystemParam;
///
/// #[derive(SystemParam)]
/// pub struct MyParam<'a> {
/// struct MyParam<'a> {
/// foo: Res<'a, usize>,
/// }
///
Expand Down
2 changes: 1 addition & 1 deletion examples/ecs/system_param.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub struct PlayerCount(usize);
///
/// In this example, it includes a query and a mutable resource.
#[derive(SystemParam)]
pub struct PlayerCounter<'a> {
struct PlayerCounter<'a> {
players: Query<'a, &'static Player>,
count: ResMut<'a, PlayerCount>,
}
Expand Down