I have this code I shamelessly copied off SO somewhere after fiddling for a few minutes trying to read the contents of a file into a string. Mine was similar to this, but I was not handling a Result somewhere.
Anyways, I was testing it just by reading crontab, and then I decided to read "/etc/cronta" to make sure that it would fail correctly. I was expecting to see "Unable to open file" here, but instead I got a thread panic.
I'm running this on ARMv7, which I'm assuming has something to do with this, so I included cat /proc/cpuinfo
Cpuinfo: cat /proc/cpuinfoprocessor : 0model name : ARMv7 Processor rev 1 - Pastebin.com
Code:
use std::fs::File;
use std::io::prelude::*;
// no idea what im doing, honestly
fn main() {
let mut d = File::open("/etc/cronta").expect("Could not open file.");
let mut contents = String::new();
d.read_to_string(&mut contents).expect("Could not read to string.");
println!("{}", contents)
}
Output: (REDACT)REDACT@localhost:~/path/you/cant/see $ cargo run Finished dev [uno - Pastebin.com
Thanks in advance. I may be slow answering this thread, but I will answer it!