1 use byteorder::{BigEndian, ByteOrder};
3 use std::io::{self, BufRead};
6 // Exercise external crate, printing to stdout.
8 let n = <BigEndian as ByteOrder>::read_u32(buf);
9 assert_eq!(n, 0x01020304);
10 println!("{:#010x}", n);
12 // Access program arguments, printing to stderr.
13 for arg in std::env::args() {
17 // If there were no arguments, access stdin.
18 if std::env::args().len() <= 1 {
20 for line in io::stdin().lock().lines() {
21 let num: i32 = line.unwrap().parse().unwrap();
22 println!("{}", 2*num);
24 // On non-Unix, reading from stdin is not support. So we hard-code the right answer.
36 use rand::{Rng, SeedableRng};
38 // Make sure in-crate tests with dev-dependencies work
41 let mut rng = rand::rngs::StdRng::seed_from_u64(0xcafebeef);
42 let x: u32 = rng.gen();
43 let y: usize = rng.gen();
44 let z: u128 = rng.gen();
45 assert_ne!(x as usize, y);
46 assert_ne!(y as u128, z);