Hi,
First time contributor here, and a relative newcomer to Rust (Iâve been at it a couple of months now, I think?). I can understand wanting something nicer for functions that return Result<(), T>, like coercing an empty statement,
fn main() -> Result<(), io::Error> {
let content = read_file(&Path::new("test.txt"))?;
println!("{}", content);
}
though I understand there are probably difficulties with making that work generally.
However, I think introducing throws and throw would be a mistake, because people coming from other languages have expectations for what they mean, and Rust would be using them very differently. Error returns are not exceptions, they donât propagate. Not only that, but the error youâre âthrowingâ isnât returned directly, itâs wrapped in an enum variant. Youâre hiding the return type behind some syntactic sugar, which may be great when you know what youâre reading, but itâs a big speedbump for a minor syntax simplification.
All this is very confusing, and a source of friction. When I started to learn Rust, I started with the Book, one of the most frustrating things was existing terms being used for very different things (though I canât think of other examples now, I guess that might be a good thing?), or new terms being introduced to explain concepts that already had widely-used names (looking at you, epochs
). Please donât make that problem worse.