simple.rs 849 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. use shr3::prelude::*;
  2. /// Example with default seed and simple get().
  3. fn example_1() {
  4. println!("example_1:");
  5. let mut shr3 = Shr3::new();
  6. for i in 0..10 {
  7. let value: u8 = shr3.get();
  8. println!("{}: 0x{:02X}", i, value);
  9. }
  10. }
  11. /// Example with default seed and get_range().
  12. fn example_2() {
  13. println!("example_2:");
  14. let mut shr3 = Shr3::new();
  15. for i in 0..10 {
  16. let value: u16 = shr3.get_range(100..200);
  17. println!("{}: {}", i, value);
  18. }
  19. }
  20. /// Example with custom seed and get_bits().
  21. fn example_3() {
  22. println!("example_3:");
  23. let mut shr3 = Shr3::new_state(12345);
  24. for i in 0..10 {
  25. let value: u16 = shr3.get_bits(10);
  26. println!("{}: 0x{:03X}", i, value);
  27. }
  28. }
  29. fn main() {
  30. example_1();
  31. example_2();
  32. example_3();
  33. }
  34. // vim: ts=4 sw=4 expandtab