Advertisement
NLinker

Initialize XorShiftRng and IsaacRng with seed

Jul 13th, 2018
422
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rust 0.49 KB | None | 0 0
  1. extern crate rand;
  2. extern crate byteorder;
  3.  
  4. use byteorder::{ByteOrder, LittleEndian as LE};
  5. use rand::{IsaacRng, XorShiftRng};
  6.  
  7. fn main() {
  8.     let mut buf = [0; 16];
  9.     {
  10.         let (mut b1, mut b2) = buf.split_at_mut(8);
  11.         byteorder::LittleEndian::write_u64(&mut b1, 123);
  12.         byteorder::LittleEndian::write_u64(&mut b2, 123);
  13.     }
  14.     let random = Rc::new(RefCell::new(XorShiftRng::from_seed(buf)));
  15.     let random = Rc::new(RefCell::new(IsaacRng::new_from_u64(123)));
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement