beginnerror 0.1.2

A simple error-handling crate for beginners.
Documentation
  • Coverage
  • 50%
    1 out of 2 items documented1 out of 2 items with examples
  • Size
  • Source code size: 1.61 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 976.21 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • Homepage
  • Repository
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • pxlmastrXD

Beginnerror

A simple error handling crate for beginners.

Quickstart

Go ahead and add the dependancy to your Cargo.toml so you can use the crate in your rust code. Then, you can use it at the top of your code:

use beginnerror::*;

Now, in your functions, you can use the Result<> to handle errors and use the ? operator.

fn getinput() -> Result<String> {
    let mut buffer = String::new();
    print!("What is your name? -> ")
    std::io::stdin.read_line(&mut buffer)?;
    Ok(buffer.to_string())
}

Then, you can handle the result.

fn main() {
    let res = getinput();
    match res {
        Ok(name) => println!("Hello, {}", name),
        Err(e) => handlerror(e.to_string());
    }
}

Simple enough, right?