From c0dd0bc2f2f395cabd869cb2eeec34304012b88d Mon Sep 17 00:00:00 2001 From: Botahamec Date: Sat, 12 Aug 2023 17:10:13 -0400 Subject: Update the version --- Cargo.toml | 2 +- README.md | 25 ++++++++++++++++++------- src/lib.rs | 25 ++++++++++++++++++------- 3 files changed, 37 insertions(+), 15 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 30faa2e..1ddea35 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "exun" -version = "0.1.0" +version = "0.2.0" authors = ["Mica White "] edition = "2018" rust-version = "1.41.1" diff --git a/README.md b/README.md index 57027c5..3a47fdc 100644 --- a/README.md +++ b/README.md @@ -5,8 +5,8 @@ don't want our programs to panic because of that. We also don't want to spend so much time handling unexpected errors. That's what this crate is for. You keep your unexpected errors, and don't worry about them until later. -* This crate works in `no-std`, although most features (besides `Exun`) require -`alloc`. +* This crate works in `no-std`. Some extra features come if `alloc` or `std` is +used. * `Exun` is an error type. It'll hold on to your `Unexpected` error if you have one, so you can figure out what to do with it later. If the error is @@ -31,7 +31,7 @@ For standard features: ```toml [dependencies] # ... -exun = "0.1" +exun = "0.2" ``` The following features are enabled by default: @@ -41,15 +41,16 @@ library's `Error` type. Using this type allows more errors to be converted into `Exun` and `RawUnexpected` errors automatically, and it's needed for `Result::unexpect`. -* `alloc`: This is needed for `Expect`, `RawUnexpected` and -`UnexpectedError`, as well as `Result::unexpected_msg`. +* `alloc`: This is needed for `RawUnexpected` and `UnexpectedError` to hold +string messages. This can be done with `Result::unexpect_mshg`. Without this, +only the equivalent of `Result::unexpect_none` can be constructed. To disable these features: ```toml [dependencies] # ... -exun = { version = "0.1", default-features = false } +exun = { version = "0.2", default-features = false } ``` If you'd like to use `alloc` but not `std`: @@ -57,7 +58,7 @@ If you'd like to use `alloc` but not `std`: ```toml [dependencies] # ... -exun = { version = "0.1", default-features = false, features = ["alloc"] } +exun = { version = "0.2", default-features = false, features = ["alloc"] } ``` ## Examples @@ -72,6 +73,16 @@ fn foo(num: &str) -> Result { } ``` +```rust +use exun::*; + +fn first(list: &[i32]) -> Result { + // for options, the `unexpect_none` method can be used + let num = list.get(0).unexpect_none()?; + Ok(num) +} +``` + ```rust use std::error::Error; use std::fmt::{self, Display}; diff --git a/src/lib.rs b/src/lib.rs index 8412e2a..faae525 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -10,8 +10,8 @@ //! so much time handling unexpected errors. That's what this crate is for. You //! keep your unexpected errors, and don't worry about them until later. //! -//! * This crate works in `no-std`, although most features (besides [`Exun`]) require -//! `alloc`. +//! * This crate works in `no-std`. Some extra features come if `alloc` or `std` is +//! used. //! //! * [`Exun`] is an error type. It'll hold on to your [`Unexpected`] error if you have //! one, so you can figure out what to do with it later. If the error is @@ -36,7 +36,7 @@ //! ```toml //! [dependencies] //! # ... -//! exun = "0.1" +//! exun = "0.2" //! ``` //! //! The following features are enabled by default: @@ -46,15 +46,16 @@ //! into [`Exun`] and [`RawUnexpected`] errors automatically, and it's needed for //! [`Result::unexpect`]. //! -//! * `alloc`: This is needed for [`Expect`], [`RawUnexpected`] and -//! [`UnexpectedError`], as well as [`Result::unexpect_msg`]. +//! * `alloc`: This is needed for `RawUnexpected` and `UnexpectedError` to hold +//! string messages. This can be done with `Result::unexpect_mshg`. Without this, +//! only the equivalent of `Result::unexpect_none` can be constructed. //! //! To disable these features: //! //! ```toml //! [dependencies] //! # ... -//! exun = { version = "0.1", default-features = false } +//! exun = { version = "0.2", default-features = false } //! ``` //! //! If you'd like to use `alloc` but not `std`: @@ -62,7 +63,7 @@ //! ```toml //! [dependencies] //! # ... -//! exun = { version = "0.1", default-features = false, features = ["alloc"] } +//! exun = { version = "0.2", default-features = false, features = ["alloc"] } //! ``` //! //! ## Examples @@ -78,6 +79,16 @@ //! } //! ``` //! +//! ```rust +//! use exun::*; +//! +//! fn first(list: &[i32]) -> Result { +//! // for options, the `unexpect_none` method can be used +//! let num = list.get(0).unexpect_none()?; +//! Ok(num) +//! } +//! ``` +//! //! ``` //! use std::error::Error; //! use std::fmt::{self, Display}; -- cgit v1.2.3