assertables

Crates.ioassertables
lib.rsassertables
version9.8.0
sourcesrc
created_at2021-04-03 19:32:43.093705+00
updated_at2025-06-23 22:32:29.010265+00
descriptionAssertables: assert macros for better testing, debugging, quality assurance, and runtime reliability.
homepage
repositoryhttps://github.com/sixarm/assertables-rust-crate/
max_upload_size
id378431
size7,196,947
Joel Parker Henderson (joelparkerhenderson)

documentation

README

Assertables: assert macros for better testing

Assertables is a Rust crate of assert macros to improve your compile-time tests and run-time reliability.

documentationsourcellms.txtcrateemail

Introduction

The Assertables Rust crate provides many assert macros that can help you develop, test, and debug.

This documentation is also available as llms.txt.

To use this crate, add it to your file Cargo.toml:

assertables = "9.8.0"

Benefits:

  • You can write better tests to improve reliability and maintainability.
  • You can handle more corner cases without needing to write custom code.
  • You can troubleshoot faster because error messages show more detail.

Learning: FAQ, docs, examples, changes, upgrades, developing.

Comparisons: more_asserts, cool_asserts, assert2, claims, etc.

Examples

Examples with numbers:

let i = 1;
assert_lt!(i, 5);
assert_diff_eq_x!(i, 5, 4);
assert_in_range!(&i, &(1..5));

Examples with strings:

let s = "hello";
assert_starts_with!(s, "h");
assert_contains!(s, "e");
assert_is_match!(Regex::new(r"h.*o").unwrap(), s);

Examples with arrays:

let a = [1, 2, 3];
assert_not_empty!(a);
assert_len_eq_x!(a, 3);
assert_all!(a.into_iter(), |i: i32| i < 4);

Highlights

Values:

Floats:

Nearness:

Groups:

Matching:

Results:

Options:

Polls:

Readers:

Iterators:

Sets:

Bags:

Commands:

Status:

Infix values:

Infix logic:

For a complete list of modules and macros, see the docs.

Forms

All the macros have forms for an optional message:

All the macros have forms for different outcomes:

Many of the macros have a form "compare left item to right item" that compares items of the same kind, and a form "compare left item to right expression" that compares one item to any arbitrary expression:

Many of the macros has a "success return", which means the macro returns data that you can optionally use for more testing.

Tracking

  • Package: assertables-rust-crate
  • Version: 9.8.0
  • Created: 2021-03-30T15:47:49Z
  • Updated: 2025-06-21T22:20:00Z
  • License: MIT or Apache-2.0 or GPL-2.0 or GPL-3.0 or contact us for more
  • Contact: Joel Parker Henderson joel@joelparkerhenderson.com
Commit count: 435

cargo fmt