Skip to content

Incompatibility with rand_core 0.9 #45

@Esteth

Description

@Esteth

The simplest program I could write to exercise bevy_rand fails to compile against rand_core 0.9 (the latest version).

use rand_core::RngCore;
use bevy::prelude::*;
use bevy_rand::prelude::{EntropyPlugin, GlobalEntropy, ChaCha8Rng};

fn main() {
    App::new()
        .add_plugins(EntropyPlugin::<ChaCha8Rng>::with_seed([1; 32]))
        .add_systems(Startup, setup_fish)
        .run();
}

fn setup_fish(
    mut rng: GlobalEntropy<ChaCha8Rng>,
) {
    let random_number = rng.next_u32();
}
error[E0599]: the method `next_u32` exists for struct `Single<'_, &mut Entropy<ChaCha8Rng>, With<Global>>`, but its trait bounds were not satisfied
...
     = note: the following trait bounds were not satisfied:
             `Mut<'_, Entropy<ChaCha8Rng>>: RngCore`
             which is required by `bevy::prelude::Single<'_, &'static mut Entropy<ChaCha8Rng>, With<bevy_rand::global::Global>>: RngCore`
             `Entropy<ChaCha8Rng>: RngCore`
             which is required by `Mut<'_, Entropy<ChaCha8Rng>>: RngCore`
             `Entropy<ChaCha8Rng>: DerefMut`
             which is required by `Entropy<ChaCha8Rng>: RngCore`
             `Entropy<ChaCha8Rng>: Deref`
             which is required by `Entropy<ChaCha8Rng>: RngCore`
     = help: items from traits can only be used if the trait is in scope
help: trait `RngCore` which provides `next_u32` is implemented but not in scope; perhaps you want to import it
     |
1    + use rand_core::RngCore;
     |

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions