Skip to content
This repository has been archived by the owner on Mar 22, 2022. It is now read-only.

Commit

Permalink
Release ready.
Browse files Browse the repository at this point in the history
  • Loading branch information
daxpedda committed Dec 27, 2018
1 parent 9d07f0b commit 2eb1079
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ before_cache:
- rm -rf "$HOME/.cargo/registry"

script:
- bash .travis/script.sh
- bash .travis/build.sh

notifications:
email:
Expand Down
40 changes: 25 additions & 15 deletions .travis/script.sh → .travis/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,47 +10,56 @@ cargo build --release --verbose || exit_code=1
# tests
cargo test --verbose || exit_code=1
cargo test --release --verbose || exit_code=1
# check if needs update
cargo update --locked --verbose || exit_code=1

# we don't want build to break just because there is something not up to date
if [ $TRAVIS_BRANCH != "release" ]; then
cargo update --locked --verbose || exit_code=1
fi

# nightly has additional features we want to use
# build documentation
if [ "$TRAVIS_RUST_VERSION" != "nightly" ]; then
if [ $TRAVIS_RUST_VERSION != "nightly" ]; then
cargo doc --verbose || exit_code=1
else
cargo rustdoc --verbose -- -Z unstable-options --enable-index-page || exit_code=1
cargo rustdoc --features doc_include --verbose -- -Z unstable-options --enable-index-page || exit_code=1
# run benchmarks
cargo bench --verbose || exit_code=1
fi

# check if clippy is present in the toolchain - because sometimes it's missing
if rustup component add clippy; then
# clippy check build and tests
cargo clippy --all-features --verbose -- -D warnings || exit_code=1
cargo clippy --all-features --tests --verbose -- -D warnings || exit_code=1
cargo clippy --verbose -- -D warnings || exit_code=1
cargo clippy --tests --verbose -- -D warnings || exit_code=1

# clippy check benches, but only in nightly, because they don't work in stable yet
if [ "$TRAVIS_RUST_VERSION" == "nightly" ]; then
cargo clippy --all-features --benches --verbose -- -D warnings || exit_code=1
if [ $TRAVIS_RUST_VERSION == "nightly" ]; then
cargo clippy --benches --verbose -- -D warnings || exit_code=1
fi
fi

# check if fmt is present in the toolchain - because sometimes it's missing
if rustup component add rustfmt; then
# also we don't want to break the build just because some formatting is broken
if rustup component add rustfmt && [ $TRAVIS_BRANCH != "release" ]; then
# check if any formatting is needed
cargo fmt --all --verbose -- --check || exit_code=1
fi

# if it's not a PR and we want to deploy, deploy!
if [ "$TRAVIS_PULL_REQUEST" == false ] && [ "$TRAVIS_RUST_VERSION" == "nightly" ]; then
# try to install packages
cargo install cargo-update || echo "cargo-update already installed"
RUSTFLAGS="--cfg procmacro2_semver_exempt" cargo install cargo-tarpaulin --git "https://github.com/xd009642/tarpaulin.git" --branch "develop" || echo "cargo-tarpaulin already installed"
cargo install cargo-travis --git "https://github.com/daxpedda/cargo-travis.git" --branch "temporary" || echo "cargo-travis already installed"
# now we just check for updates
if [ $TRAVIS_PULL_REQUEST == false ] && [ $TRAVIS_RUST_VERSION == "nightly" ]; then
# install and update packages
cargo install cargo-update
cargo install-update cargo-update
cargo install cargo-audit
cargo install-update cargo-audit
RUSTFLAGS="--cfg procmacro2_semver_exempt" cargo install cargo-tarpaulin --git "https://github.com/xd009642/tarpaulin.git" --branch "develop"
RUSTFLAGS="--cfg procmacro2_semver_exempt" cargo install-update cargo-tarpaulin -g
cargo install cargo-travis --git "https://github.com/daxpedda/cargo-travis.git" --branch "temporary"
cargo install-update cargo-travis -g

# check rust RustSec db
cargo audit || exit_code=1

# decrypt deploy key
echo $github_deploy_key | gpg --passphrase-fd 0 ".travis/github_deploy_key.gpg"
chmod 600 ".travis/github_deploy_key"
Expand All @@ -59,6 +68,7 @@ if [ "$TRAVIS_PULL_REQUEST" == false ] && [ "$TRAVIS_RUST_VERSION" == "nightly"
ssh-add ".travis/github_deploy_key"
# upload documentation
cargo doc-upload --branch $TRAVIS_BRANCH --clobber-index || exit_code=1

# do some test coverage
cargo tarpaulin --out Xml --ignore-tests --verbose || exit_code=1
bash <(curl -s https://codecov.io/bash) || exit_code=1
Expand Down
6 changes: 5 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ readme = "README.MD"
keywords = ["unwrap", "unchecked", "expect", "result", "option"]
categories = ["no-std", "rust-patterns"]
license = "MIT OR Apache-2.0"
exclude = [".travis.yml"]
exclude = ["/.travis.yml", "/.github/*", "/.travis/*"]

[badges]
travis-ci = { repository = "daxpedda/unchecked_unwrap", branch = "stable" }
Expand All @@ -25,7 +25,11 @@ maintenance = { status = "actively-developed" }
[features]
default = ["debug_checks"]
debug_checks = []
doc_include = []

[lib]
test = false
bench = false

[package.metadata.docs.rs]
features = ["doc_include"]
19 changes: 15 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

[![Crates.io](https://img.shields.io/crates/v/unchecked_unwrap.svg)](https://crates.io/crates/unchecked_unwrap/)
[![Deps.rs](https://deps.rs/repo/github/daxpedda/unchecked_unwrap/status.svg)](https://deps.rs/repo/github/daxpedda/unchecked_unwrap)
[![Commits since](https://img.shields.io/github/commits-since/daxpedda/unchecked_unwrap/latest.svg)](https://github.com/daxpedda/unchecked_unwrap/releases/latest/)
[![Resolution](http://isitmaintained.com/badge/resolution/daxpedda/unchecked_unwrap.svg)](http://isitmaintained.com/project/daxpedda/unchecked_unwrap)
[![Issues](http://isitmaintained.com/badge/open/daxpedda/unchecked_unwrap.svg)](http://isitmaintained.com/project/daxpedda/unchecked_unwrap)
[![License](https://img.shields.io/crates/l/unchecked_unwrap.svg)](https://github.com/daxpedda/unchecked_unwrap/blob/master/LICENSE)
Expand All @@ -14,16 +15,16 @@

**[Master](https://github.com/daxpedda/unchecked_unwrap/):**
[![Build](https://img.shields.io/travis/daxpedda/unchecked_unwrap/master.svg?label=build:%20master)](https://travis-ci.org/daxpedda/unchecked_unwrap/branches/)
[![Docs](https://github.com/daxpedda/unchecked_unwrap/blob/gh-pages/master/badge.svg)](https://daxpedda.github.io/unchecked_unwrap/master/index.html)
[![Docs](https://raw.githack.com/daxpedda/unchecked_unwrap/gh-pages/master/badge.svg)](https://daxpedda.github.io/unchecked_unwrap/master/index.html)
[![Coverage](https://img.shields.io/codecov/c/github/daxpedda/unchecked_unwrap/master.svg?label=coverage:%20master)](https://codecov.io/github/daxpedda/unchecked_unwrap/branch/master/)

Adds an unchecked version of `unwrap()` and `expect()` to `Option` and `Result` for the rust programmming language.
Supports `no_std`.

## Branches

* **release** - For releases only.
* **master** - For active development, PR's and testing.
* **[release](https://github.com/daxpedda/unchecked_unwrap/tree/release/)** - For releases only.
* **[master](https://github.com/daxpedda/unchecked_unwrap/)** - For active development, PR's and testing.

## Usage

Expand All @@ -47,7 +48,13 @@ assert_eq!(unsafe { x.unchecked_expect("the sky is falling down") }, 2);

**debug_checks**: On by default. Enables the normal checking behavior with panics when `debug-assertions` is enabled.

## Testing
## Documentation

Documentation is available online in the badge links above.
Currently nightly is needed for full documentation: `cargo doc --features doc_include`
If you are not on nightly only use `cargo doc`.

## Tests

Is as simple as `cargo test` and `cargo test --release`.

Expand All @@ -61,6 +68,10 @@ I removed the badge from [Crates.io](https://crates.io/crates/unchecked_unwrap/)
Is as simple as `cargo bench`.
Currently the nightly version of rust is needed for benchmarking.

## CI

This crate is checked daily by CI to make sure that it builds successfully with the newest versions rust stable, beta and nightly.

## Alternatives

* **[unsafe-unwrap-rs](https://github.com/nvzqz/unsafe-unwrap-rs/)** - [![Crates.io](https://img.shields.io/crates/v/unsafe-unwrap.svg)](https://crates.io/crates/unsafe-unwrap/)
Expand Down
8 changes: 8 additions & 0 deletions bench.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
671 ns/iter (+/- 11) checked::expect_option
670 ns/iter (+/- 8) checked::expect_result
672 ns/iter (+/- 7) checked::unwrap_option
670 ns/iter (+/- 15) checked::unwrap_result
296 ns/iter (+/- 21) unchecked::expect_option
295 ns/iter (+/- 129) unchecked::expect_result
295 ns/iter (+/- 30) unchecked::unwrap_option
295 ns/iter (+/- 13) unchecked::unwrap_result
6 changes: 2 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#![feature(external_doc)]

#![no_std]
#![warn(clippy::cargo, clippy::pedantic, clippy::nursery)]

#![doc(include = "../README.md")]
#![cfg_attr(feature = "doc_include", feature(external_doc))]
#![cfg_attr(feature = "doc_include", doc(include = "../README.md"))]

/// Trait for [`unchecked_expect`](trait.UncheckedExpect.html#method.unchecked_expect).
pub trait UncheckedExpect<T> {
Expand Down

0 comments on commit 2eb1079

Please sign in to comment.