use std::convert::TryInto; use std::fs::File; use std::io::Read; use std::path::Path; pub fn load_small_file

(name: P, max_size: u64) -> Vec where P: AsRef { let mut f = File::open (name).unwrap (); let len = f.metadata ().unwrap ().len (); if len > max_size { panic! ("File is too big"); } let mut data = vec! [0u8; len.try_into ().unwrap ()]; f.read_exact (&mut data [..]).unwrap (); data }