comparison examples/stagerunner.rs @ 752:5e5e7136ac92

examples: Return a Result for load_file_into_vec()
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Wed, 29 Jan 2020 17:45:25 +0100
parents 0fed350d1778
children a662dddd4a2b
comparison
equal deleted inserted replaced
751:eab7dde1164f 752:5e5e7136ac92
98 let directory = Path::new(&args[1]); 98 let directory = Path::new(&args[1]);
99 let stage_number: u8 = args[2].parse().expect("stage"); 99 let stage_number: u8 = args[2].parse().expect("stage");
100 let rank: Rank = args[3].parse().expect("rank"); 100 let rank: Rank = args[3].parse().expect("rank");
101 101
102 // Open the ECL file. 102 // Open the ECL file.
103 let buf = load_file_into_vec(directory.join(format!("ecldata{}.ecl", stage_number))); 103 let buf = load_file_into_vec(directory.join(format!("ecldata{}.ecl", stage_number))).unwrap();
104 let (_, ecl) = Ecl::from_slice(&buf).unwrap(); 104 let (_, ecl) = Ecl::from_slice(&buf).unwrap();
105 assert_eq!(ecl.mains.len(), 1); 105 assert_eq!(ecl.mains.len(), 1);
106 let main = ecl.mains[0].clone(); 106 let main = ecl.mains[0].clone();
107 107
108 // Open the ANM file. 108 // Open the ANM file.
109 let anm_filename = directory.join(format!("stg{}enm.anm", stage_number)); 109 let anm_filename = directory.join(format!("stg{}enm.anm", stage_number));
110 let buf = load_file_into_vec(&anm_filename); 110 let buf = load_file_into_vec(&anm_filename).unwrap();
111 let (_, mut anms) = Anm0::from_slice(&buf).unwrap(); 111 let (_, mut anms) = Anm0::from_slice(&buf).unwrap();
112 let anm0 = anms.pop().unwrap(); 112 let anm0 = anms.pop().unwrap();
113 113
114 // Open the second ANM file. 114 // Open the second ANM file.
115 let anm2_filename = directory.join(format!("stg{}enm2.anm", stage_number)); 115 let anm2_filename = directory.join(format!("stg{}enm2.anm", stage_number));
116 let buf = load_file_into_vec(&anm2_filename); 116 let buf = load_file_into_vec(&anm2_filename).unwrap();
117 let (_, mut anms) = Anm0::from_slice(&buf).unwrap(); 117 let (_, mut anms) = Anm0::from_slice(&buf).unwrap();
118 let anm0_bis = anms.pop().unwrap(); 118 let anm0_bis = anms.pop().unwrap();
119 119
120 let anms = [anm0, anm0_bis]; 120 let anms = [anm0, anm0_bis];
121 121