Debian Codegraph @

third_party/rust/ohttp/src/rand.rs

raw
1 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
2 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
3 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
4 // option. This file may not be copied, modified, or distributed
5 // except according to those terms.
6
7 use ::rand::{thread_rng, RngCore};
8
9 #[must_use]
10 pub fn random(size: usize) -> Vec<u8> {
11 let mut rng = thread_rng();
12 let mut buf = vec![0; size];
13 rng.fill_bytes(&mut buf);
14 buf
15 }