1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
use crate::{Resource, World};
#[cfg(feature = "nightly")]
macro_rules! fetch_panic {
    () => {{
        panic!(
            "Tried to fetch a resource of type {:?}, but the resource does not exist.\n\
             Try adding the resource by inserting it manually or using the `setup` method.",
            unsafe { ::std::intrinsics::type_name::<T>() },
        )
    }};
}
#[cfg(not(feature = "nightly"))]
macro_rules! fetch_panic {
    () => {{
        panic!(
            "Tried to fetch a resource, but the resource does not exist.\n\
             Try adding the resource by inserting it manually or using the `setup` method.\n\
             You can get the type name of the missing resource by enabling `shred`'s `nightly` \
             feature"
        )
    }};
}
pub struct DefaultProvider;
impl<T> SetupHandler<T> for DefaultProvider
where
    T: Default + Resource,
{
    fn setup(world: &mut World) {
        world.entry().or_insert_with(T::default);
    }
}
pub trait SetupHandler<T>: Sized {
    
    fn setup(world: &mut World);
}
pub struct PanicHandler;
impl<T> SetupHandler<T> for PanicHandler
where
    T: Resource,
{
    fn setup(_: &mut World) {}
}