Rand::rngs:: thread ::ThreadRng

I want to use this type for my func:

impl Data {
        fn get_rand_num(thread:&rand::rngs::thread::ThreadRng) ->u8 {
            thread.gen_range(0..=30)
        }
    }

but module thread is private

how can I implement it?

Why do you want to do this? Why not either make your function generic or bind the thread-local rng within the body of the function?

and how do I make a generic function?.I just haven't reached this part of the book yet

rand::rngs::ThreadRng is the public path to ThreadRng in rand 0.8.5

1 Like

thank you

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.