-
-
Notifications
You must be signed in to change notification settings - Fork 856
Closed
Labels
Description
In rust-random/rand#325 I am trying to add serde to struct, with no luck. I am kind of lost in the trait bound errors. Can you help me out?
By now I have serialization working, but no idea where to start with deserialization.
Is is about a struct where one field is a generic:
pub struct BlockRng<R: BlockRngCore + ?Sized> {
pub results: R::Results,
pub index: usize,
pub core: R,
}
pub trait BlockRngCore {
type Item;
/// Results type. This is the 'block' an RNG implementing `BlockRngCore`
/// generates, which will usually be an array like `[u32; 16]`.
type Results: AsRef<[Self::Item]> + AsMut<[Self::Item]> + Default;
/// Generate a new block of results.
fn generate(&mut self, results: &mut Self::Results);
}
Please see the linked PR for my latest attempt.