xpct/format/
mod.rs

1//! The formatters provided by this crate.
2//!
3//! The formatters in this module can be used to implement custom matchers without having to
4//! manually implement their formatting logic. You can use these formatters to get pretty formatting
5//! for free.
6//!
7//! If you're just writing tests and not writing custom matchers or formatters, you don't need
8//! anything in this module.
9//!
10//! The [`Format::Value`] of a formatter tells you what failure output it accepts. For example,
11//! [`MismatchFormat`] can format any matcher that returns a [`Mismatch`].
12//!
13//! See [Writing Custom Matchers][crate::docs::writing_matchers] to learn how to implement your own
14//! matchers that use these provided formatters.
15//!
16//! See [Writing Custom Formatters][crate::docs::writing_formatters] to learn how to implement your
17//! own formatters like the ones in this module.
18//!
19//! [`Format::Value`]: crate::core::Format::Value
20//! [`Mismatch`]: crate::matchers::Mismatch
21
22#![cfg(feature = "fmt")]
23
24mod all;
25mod any;
26mod boolean;
27mod casefold;
28mod contain;
29mod default;
30#[cfg(feature = "diff")]
31mod diffing;
32mod each;
33mod elements;
34mod equal;
35mod every;
36mod fields;
37mod file;
38mod float;
39mod json;
40mod len;
41mod map;
42mod not;
43mod option;
44mod ord;
45mod pattern;
46mod regex;
47mod result;
48mod substr;
49mod time;
50mod why;
51mod zero;
52
53/// Types for styling formatted diffs.
54#[cfg(feature = "diff")]
55pub mod diff {
56    pub use super::diffing::{
57        CollectionDiffStyle, DiffFormat, DiffSegmentStyle, DiffStyle, StringDiffStyle,
58    };
59}
60
61pub use any::HeaderFormat;
62pub use boolean::MessageFormat;
63pub use each::SomeFailuresFormat;
64pub use equal::MismatchFormat;
65pub use fields::ByFieldFormat;
66pub use map::InfallibleFormat;
67pub use not::FailureFormat;
68pub use option::ExpectationFormat;
69pub use why::WhyFormat;
70
71#[cfg(feature = "diff")]
72pub use diffing::DiffFormat;
73
74pub(crate) mod matchers {
75    pub use super::all::all;
76    pub use super::any::any;
77    pub use super::boolean::{be_false, be_true};
78    pub use super::contain::{be_in, consist_of, contain_element, contain_elements};
79    pub use super::default::be_default;
80    pub use super::each::each;
81    pub use super::elements::match_elements;
82    pub use super::equal::equal;
83    pub use super::every::every;
84    pub use super::fields::{match_any_fields, match_fields};
85    pub use super::file::{be_directory, be_existing_file, be_regular_file, be_symlink};
86    pub use super::len::{be_empty, have_len};
87    pub use super::map::{into, iter_map, iter_try_map, map, try_into, try_map};
88    pub use super::not::not;
89    pub use super::option::{be_none, be_some};
90    pub use super::ord::{be_ge, be_gt, be_le, be_lt, be_sorted_asc, be_sorted_by, be_sorted_desc};
91    pub use super::pattern::match_pattern;
92    pub use super::result::{be_err, be_ok};
93    pub use super::substr::{contain_substr, have_prefix, have_suffix};
94    pub use super::time::approx_eq_time;
95    pub use super::why::{why, why_lazy};
96    pub use super::zero::be_zero;
97
98    #[cfg(feature = "diff")]
99    pub use super::diffing::eq_diff;
100
101    #[cfg(feature = "casefold")]
102    pub use super::casefold::eq_casefold;
103
104    #[cfg(feature = "float")]
105    pub use super::float::{approx_eq_f32, approx_eq_f64};
106
107    #[cfg(feature = "json")]
108    pub use super::json::match_json;
109
110    #[cfg(feature = "regex")]
111    pub use super::regex::match_regex;
112}