use immutable reference in FromResources

This commit is contained in:
Carter Anderson 2020-04-30 23:59:05 -07:00
parent 3e3ab92ff5
commit 45a1f0515f
2 changed files with 4 additions and 4 deletions

View File

@ -2,14 +2,14 @@ use crate::{EventReader, GetEventReader};
use legion::prelude::Resources;
pub trait FromResources {
fn from_resources(resources: &mut Resources) -> Self;
fn from_resources(resources: &Resources) -> Self;
}
impl<T> FromResources for T
where
T: Default,
{
default fn from_resources(_resources: &mut Resources) -> Self {
default fn from_resources(_resources: &Resources) -> Self {
Self::default()
}
}
@ -18,7 +18,7 @@ impl<T> FromResources for EventReader<T>
where
T: Send + Sync + 'static,
{
fn from_resources(resources: &mut Resources) -> Self {
fn from_resources(resources: &Resources) -> Self {
resources.get_event_reader::<T>()
}
}

View File

@ -143,7 +143,7 @@ pub fn derive_resource(input: TokenStream) -> TokenStream {
TokenStream::from(quote! {
impl #impl_generics #bevy_app_path::FromResources for #struct_name#ty_generics {
fn from_resources(resources: &mut Resources) -> Self {
fn from_resources(resources: &Resources) -> Self {
use #bevy_app_path::FromResources;
#struct_name {
#(#fields: <#field_types>::from_resources(resources),)*