Skip to content

Commit 60a515c

Browse files
committed
Move the Typed trait bound to SeedableEntropySource.
This trait already holds the majority of trait requirements, so we might as well add it there as well.
1 parent 96325a2 commit 60a515c

File tree

3 files changed

+11
-15
lines changed

3 files changed

+11
-15
lines changed

bevy_prng/src/lib.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use std::fmt::Debug;
2323

2424
use bevy::{
2525
prelude::{FromReflect, Reflect},
26-
reflect::{GetTypeRegistration, TypePath},
26+
reflect::{GetTypeRegistration, TypePath, Typed},
2727
};
2828
use rand_core::{RngCore, SeedableRng};
2929
#[cfg(feature = "serialize")]
@@ -46,7 +46,7 @@ pub use xoshiro::*;
4646
#[cfg(feature = "serialize")]
4747
pub trait SeedableEntropySource:
4848
RngCore
49-
+ SeedableRng
49+
+ SeedableRng<Seed: Typed>
5050
+ Clone
5151
+ Debug
5252
+ PartialEq
@@ -56,6 +56,7 @@ pub trait SeedableEntropySource:
5656
+ TypePath
5757
+ FromReflect
5858
+ GetTypeRegistration
59+
+ Typed
5960
+ Serialize
6061
+ for<'a> Deserialize<'a>
6162
+ private::SealedSeedable
@@ -106,7 +107,7 @@ impl<
106107
#[cfg(not(feature = "serialize"))]
107108
pub trait SeedableEntropySource:
108109
RngCore
109-
+ SeedableRng
110+
+ SeedableRng<Seed: Typed>
110111
+ Clone
111112
+ Debug
112113
+ PartialEq
@@ -115,6 +116,7 @@ pub trait SeedableEntropySource:
115116
+ TypePath
116117
+ FromReflect
117118
+ GetTypeRegistration
119+
+ Typed
118120
+ Sync
119121
+ Send
120122
+ private::SealedSeedable

src/plugin.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
use crate::{component::EntropyComponent, resource::GlobalEntropy, seed::RngSeed};
2-
use bevy::{
3-
prelude::{App, Plugin},
4-
reflect::Typed,
5-
};
2+
use bevy::prelude::{App, Plugin};
63
use bevy_prng::{EntropySeed, SeedableEntropySource};
74
use rand_core::SeedableRng;
85

@@ -63,9 +60,9 @@ where
6360
}
6461
}
6562

66-
impl<R: SeedableEntropySource + Typed + 'static> Plugin for EntropyPlugin<R>
63+
impl<R: SeedableEntropySource + 'static> Plugin for EntropyPlugin<R>
6764
where
68-
R::Seed: EntropySeed + Typed,
65+
R::Seed: EntropySeed,
6966
{
7067
fn build(&self, app: &mut App) {
7168
app.register_type::<GlobalEntropy<R>>()

src/resource.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,7 @@ use crate::{
88
ForkableRng, ForkableSeed,
99
},
1010
};
11-
use bevy::{
12-
prelude::{Reflect, ReflectFromReflect, ReflectFromWorld, ReflectResource, Resource},
13-
reflect::Typed,
14-
};
11+
use bevy::prelude::{Reflect, ReflectFromReflect, ReflectFromWorld, ReflectResource, Resource};
1512
use bevy_prng::SeedableEntropySource;
1613
use rand_core::{RngCore, SeedableRng};
1714

@@ -65,8 +62,8 @@ use serde::{Deserialize, Serialize};
6562
feature = "serialize",
6663
serde(bound(deserialize = "R: for<'a> Deserialize<'a>, R::Seed: for<'a> Deserialize<'a>"))
6764
)]
68-
#[cfg_attr(feature = "serialize", reflect(where R::Seed: PartialEq + Debug + Sync + Send + Clone + Serialize + Typed + for<'a> Deserialize<'a>))]
69-
#[cfg_attr(not(feature = "serialize"), reflect(where R::Seed: PartialEq + Debug + Sync + Send + Clone + Typed))]
65+
#[cfg_attr(feature = "serialize", reflect(where R::Seed: PartialEq + Debug + Sync + Send + Clone + Serialize + for<'a> Deserialize<'a>))]
66+
#[cfg_attr(not(feature = "serialize"), reflect(where R::Seed: PartialEq + Debug + Sync + Send + Clone))]
7067
pub struct GlobalEntropy<R: SeedableEntropySource + 'static> {
7168
seed: R::Seed,
7269
rng: R,

0 commit comments

Comments
 (0)