Skip to content

Commit d508923

Browse files
committed
Allow deriving SystemParam on private types (#1936)
Examples creating a public type to derive `SystemParam` on were updated to create a private type where a public one is no longer needed. Resolves #1869
1 parent cf221f9 commit d508923

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

crates/bevy_ecs/macros/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,13 +373,14 @@ pub fn derive_system_param(input: TokenStream) -> TokenStream {
373373

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

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

382-
pub struct #fetch_struct_name<TSystemParamState, #punctuated_generic_idents> {
383+
#fetch_struct_visibility struct #fetch_struct_name<TSystemParamState, #punctuated_generic_idents> {
383384
state: TSystemParamState,
384385
marker: std::marker::PhantomData<(#punctuated_generic_idents)>
385386
}

crates/bevy_ecs/src/system/system_param.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use std::{
2525
/// use bevy_ecs::system::SystemParam;
2626
///
2727
/// #[derive(SystemParam)]
28-
/// pub struct MyParam<'a> {
28+
/// struct MyParam<'a> {
2929
/// foo: Res<'a, usize>,
3030
/// }
3131
///

examples/ecs/system_param.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub struct PlayerCount(usize);
1717
///
1818
/// In this example, it includes a query and a mutable resource.
1919
#[derive(SystemParam)]
20-
pub struct PlayerCounter<'a> {
20+
struct PlayerCounter<'a> {
2121
players: Query<'a, &'static Player>,
2222
count: ResMut<'a, PlayerCount>,
2323
}

0 commit comments

Comments
 (0)