Skip to content

Commit

Permalink
Merge #3
Browse files Browse the repository at this point in the history
3: add expect_macro r=killercup a=vitiral

This PR adds the `expect!` macro, which is an ergonomic replacement for `unwrap()`/`expect()`. The main advantages are:

- Prints the line number/column of the failure with a better error message.
- Can specify format parameters (The type of `expect` is `expect(&str)`, so you have to use `&format!(...)`)
- Error conditions are lazily evaluated.
  • Loading branch information
bors[bot] committed Feb 8, 2018
2 parents 001ab08 + bc293ec commit 54d9a9b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ repository = "https://github.com/rust-crates/ergo_std"
version = "0.0.1"

[dependencies]
expect_macro = "0.1.0"
itertools = "0.7"
lazy_static = "1.0"
maplit = "1.0"
Expand Down
4 changes: 4 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
//! - [**serde**](https://github.com/serde-rs/serde): Serialization framework for Rust
//! - [**std_prelude**](https://github.com/vitiral/std_prelude): prelude that the rust stdlib
//! should have always had
//! - [**expect_macro**](https://github.com/vitiral/expect_macro): The `expect!` macro
//! - [**lazy_static**](https://github.com/rust-lang-nursery/lazy-static.rs): A small macro for
//! defining lazy evaluated static variables in Rust.
//! - [**itertools**](https://github.com/bluss/rust-itertools): Extra iterator adaptors, iterator
Expand All @@ -69,6 +70,8 @@
//! Consider supporting their development individually and starring them on github.
#![allow(unused_imports)]

#[macro_use]
pub extern crate expect_macro;
#[macro_use]
pub extern crate itertools;
#[macro_use]
Expand All @@ -81,6 +84,7 @@ pub extern crate serde;
#[macro_use]
pub extern crate serde_derive;

pub use expect_macro::*;
pub use std_prelude::*;
pub use lazy_static::*;
pub use itertools::Itertools;
Expand Down

0 comments on commit 54d9a9b

Please sign in to comment.