4 ms·
TypeScript has just as few characters/lines as your Rust example: if (file === null) throw new Error("File must exist"); vs.: let file = file.ok_or(E
by erichocean 6y ago
TypeScript has just as few characters/lines as your Rust example:
if (file === null) throw new Error("File must exist");
vs.:
let file = file.ok_or(Error::new("File must exist"))?;
It's also easier to type (5 non-numeric characters vs. 8 in Rust), and IMO it's easier to read and requires less tribal knowledge. (Also could be just 4 non-numeric characters in TypeScript since the semi-colon is not required.)