@@ -3,8 +3,6 @@ use core::{
33 num:: { NonZeroU128 , NonZeroU32 , NonZeroU64 , NonZeroUsize } ,
44} ;
55
6- use serde:: { Deserialize , Deserializer , Serialize , Serializer } ;
7-
86use necsim_core:: cogs:: {
97 distribution:: {
108 Bernoulli , Exponential , IndexU128 , IndexU32 , IndexU64 , IndexUsize , Lambda , Length , Normal ,
@@ -23,20 +21,18 @@ pub struct SimpleRng<M: MathsCore, R: RngCore> {
2321 marker : PhantomData < M > ,
2422}
2523
26- impl < M : MathsCore , R : RngCore > Serialize for SimpleRng < M , R > {
27- fn serialize < S : Serializer > ( & self , serializer : S ) -> Result < S :: Ok , S :: Error > {
28- self . inner . serialize ( serializer)
24+ impl < M : MathsCore , R : RngCore > From < R > for SimpleRng < M , R > {
25+ fn from ( inner : R ) -> Self {
26+ Self {
27+ inner,
28+ marker : PhantomData :: < M > ,
29+ }
2930 }
3031}
3132
32- impl < ' de , M : MathsCore , R : RngCore > Deserialize < ' de > for SimpleRng < M , R > {
33- fn deserialize < D : Deserializer < ' de > > ( deserializer : D ) -> Result < Self , D :: Error > {
34- let inner = R :: deserialize ( deserializer) ?;
35-
36- Ok ( Self {
37- inner,
38- marker : PhantomData :: < M > ,
39- } )
33+ impl < M : MathsCore , R : RngCore > SimpleRng < M , R > {
34+ pub fn into ( self ) -> R {
35+ self . inner
4036 }
4137}
4238
@@ -50,23 +46,6 @@ impl<M: MathsCore, R: RngCore> Backup for SimpleRng<M, R> {
5046 }
5147}
5248
53- impl < M : MathsCore , R : RngCore > RngCore for SimpleRng < M , R > {
54- type Seed = R :: Seed ;
55-
56- #[ must_use]
57- fn from_seed ( seed : Self :: Seed ) -> Self {
58- Self {
59- inner : R :: from_seed ( seed) ,
60- marker : PhantomData :: < M > ,
61- }
62- }
63-
64- #[ must_use]
65- fn sample_u64 ( & mut self ) -> u64 {
66- self . inner . sample_u64 ( )
67- }
68- }
69-
7049impl < M : MathsCore , R : RngCore > Rng < M > for SimpleRng < M , R > {
7150 type Generator = R ;
7251 type Sampler = SimplerDistributionSamplers < M , R > ;
@@ -84,7 +63,7 @@ impl<M: MathsCore, R: RngCore> Rng<M> for SimpleRng<M, R> {
8463 }
8564 }
8665
87- fn with_rng < F : FnOnce ( & mut Self :: Generator , & Self :: Sampler ) -> Q , Q > ( & mut self , inner : F ) -> Q {
66+ fn with < F : FnOnce ( & mut Self :: Generator , & Self :: Sampler ) -> Q , Q > ( & mut self , inner : F ) -> Q {
8867 let samplers = SimplerDistributionSamplers {
8968 _marker : PhantomData :: < ( M , R ) > ,
9069 } ;
0 commit comments