Skip to content

Instantly share code, notes, and snippets.

Fun with loops

Let's say you have a function which reads in a file, converts it into a script, and returns a Result. It takes one argument: the name of the file to load.

struct Script;
type ParseError = Box<dyn std::error::Error>;

fn load_script(_filename: &str) -> Result<Script, ParseError> {
  // open file, parse data, return Err(ParseError) on failure

Keybase proof

I hereby claim:

  • I am mjmusante on github.
  • I am mmusante (https://keybase.io/mmusante) on keybase.
  • I have a public key ASAyq_aKXhuZCoU_K6DIdVnHuj8R6MvPZOeoPHK6iX6SeQo

To claim this, I am signing this object: