I'm creating some ports based on arguments, but the ports don't live long enough to be passed to the next function, any lifetime-fu to be done? Better still, a way to adapt this to statically dispatch?
fn init<'a>(matches: getopts::Matches) {
let in_port: &mut Read = match matches.opt_str("i") {
Some(filename) => &mut File::open(filename).expect("Couldn't open input file.") as &mut Read,
_ => &mut io::stdin() as &mut Read,
};
let out_port: &mut Write = match matches.opt_str("o") {
Some(filename) => &mut File::create(filename).expect("Couln't open output file") as &mut Write,
_ => &mut io::stdout() as &mut Write,
};
run(in_port, out_port);
}