asserting/
lib.rs

1//! Fluent assertions for tests in Rust that are convenient to write and easy
2//! to extend.
3//!
4//! Fluent assertions have some significant advantages - in general and
5//! particularly as provided by this crate:
6//!
7//! * express the intent of an assertion
8//! * an assertion reads more like natural english
9//! * concise and expressive assertions for more complex types like collections
10//! * distinct and more helpful error messages for specific assertions
11//! * easy spotting the difference between the expected and the actual value
12//! * chaining of multiple assertions on the same subject
13//! * soft assertions
14//!
15//! An additional benefit of `asserting` is that it highlights differences
16//! between the expected value and the actual value for failed assertions.
17//! See the documentation of the [`colored`] module for more information on
18//! "colored diffs".
19//!
20//! # Usage
21//!
22//! To write fluent assertions in tests, import this crate's `prelude`
23//! module in your test module, like so:
24//!
25//! ```
26//! use asserting::prelude::*;
27//! ```
28//!
29//! Importing the `prelude` module is the intended way to use this crate. The
30//! prelude re-exports all types, traits and functions and macros that are
31//! needed to write assertions in tests.
32//!
33//! Start writing assertion by applying the [`assert_that!`] macro to the subject
34//! to be asserted. Then call an assertion
35//! function like `is_equal_to`, like so:
36//!
37//! ```
38//! # use asserting::prelude::*;
39//! let some_result = 7 * 6;
40//! assert_that!(some_result).is_equal_to(42);
41//! ```
42//!
43//! The subject can be any expression, e.g.:
44//!
45//! ```
46//! # use asserting::prelude::*;
47//! assert_that!(6 * 8 - 6).is_equal_to(42);
48//! ```
49//!
50//! The variable or expression inside the call of the [`assert_that!`] macro is
51//! repeated in the error message when an assertion fails. For example, the
52//! assertion:
53//!
54//! ```no_run
55//! # use asserting::prelude::*;
56//! assert_that!(6 * 8 - 5).is_equal_to(42);
57//! ```
58//!
59//! will print the error message:
60//!
61//! ```console
62//! expected 6 * 8 - 5 to be equal to 42
63//!    but was: 43
64//!   expected: 42
65//! ```
66//!
67//! By default, the differences between the expected value and the actual value
68//! are highlighted using colors. See the [`colored`] module for more
69//! information on "colored diffs".
70//!
71//! # Examples
72//!
73//! ## Basic assertions
74//!
75//! ```
76//! use asserting::prelude::*;
77//!
78//! assert_that!(3 + 5).is_equal_to(8);
79//! assert_that!(69).is_not_equal_to(42);
80//!
81//! assert_that!(5).is_greater_than(3);
82//! assert_that!(42).is_at_most(99);
83//!
84//! assert_that!(-0.57).is_in_range(-1.0..=1.0);
85//! assert_that!('M').is_in_range('A'..='Z');
86//! assert_that!('M').is_not_in_range('a'..='z');
87//!
88//! let subject = "at invidunt quis placerat".to_string();
89//! assert_that!(subject).is_equal_to("at invidunt quis placerat");
90//!
91//! let subject = "justo clita in stet".to_string();
92//! assert_that!(subject).is_same_as("justo clita in stet".to_string());
93//!
94//! let subject = "anim proident eiusmod sint".to_string();
95//! assert_that!(subject).contains("eiusmod");
96//!
97//! let subject = Some("consectetur veniam at nulla".to_string());
98//! assert_that!(subject).has_value("consectetur veniam at nulla");
99//!
100//! let subject: Result<i8, String> = Ok(42);
101//! assert_that!(subject).has_value(42);
102//!
103//! let subject: Option<f64> = None;
104//! assert_that!(subject).is_none();
105//!
106//! let subject: Result<(), String> = Err("labore qui eu illum".to_string());
107//! assert_that!(subject).has_error("labore qui eu illum");
108//!
109//! let subject = vec![1, 3, 5, 7, 9, 11];
110//! assert_that!(subject).contains_exactly([1, 3, 5, 7, 9, 11]);
111//! ```
112//!
113//! ## Chaining assertions on the same subject
114//!
115//! ```
116//! use asserting::prelude::*;
117//!
118//! assert_that!("commodo nobis cum duis")
119//!     .starts_with("commodo")
120//!     .ends_with(" duis")
121//!     .has_length(22);
122//!
123//! assert_that!(vec![1, 19, 1, 29, 5, 5, 7, 23, 17, 11, 3, 23, 13, 1])
124//!     .contains_all_of([1, 11, 13, 17, 19])
125//!     .contains_only([1, 3, 5, 7, 9, 11, 13, 17, 19, 23, 29, 31, 37, 43]);
126//! ```
127//!
128//! ## Asserting some elements of a collection or an iterator
129//!
130//! Asserting some elements of a collection or an iterator:
131//!
132//! ```
133//! use asserting::prelude::*;
134//!
135//! let numbers = [2, 4, 6, 8, 10];
136//!
137//! assert_that!(numbers).each_element(|e|
138//!     e.is_greater_than(1)
139//!         .is_at_most(10)
140//! );
141//!
142//! assert_that!(numbers).any_element(|e|
143//!     e.is_equal_to(4)
144//! );
145//! ```
146//!
147//! See [`Spec::each_element()`] for more details.
148//!
149//! Assert some elements of a collection or an iterator to satisfy a predicate:
150//!
151//! ```
152//! use asserting::prelude::*;
153//!
154//! let subject = [1, 41, 43, 42, 5];
155//! assert_that!(subject).any_satisfies(|e| *e == 42);
156//!
157//! let subject = [43, 44, 45, 46, 47];
158//! assert_that!(subject).all_satisfy(|e| *e > 42);
159//!
160//! let subject = [42, 43, 44, 45, 46];
161//! assert_that!(subject).none_satisfies(|e| *e < 42);
162//! ```
163//!
164//! See [`AssertElements`] for more details.
165//!
166//! ## Asserting specific elements of a collection or an iterator
167//!
168//! Filter assertions are handy to assert specific elements of a collection or
169//! an iterator.
170//!
171//! Assert the only element of a collection or an iterator:
172//!
173//! ```
174//! use asserting::prelude::*;
175//!
176//! let subject = ["single"];
177//!
178//! assert_that!(subject).single_element().is_equal_to("single");
179//! ```
180//!
181//! Assert the first, the last, or the nth element of a collection or an iterator:
182//!
183//! ```
184//! use asserting::prelude::*;
185//!
186//! let numbers = [1, 2, 3, 4, 5];
187//!
188//! assert_that!(numbers).first_element().is_equal_to(1);
189//! assert_that!(numbers).last_element().is_equal_to(5);
190//! assert_that!(numbers).nth_element(3).is_equal_to(4);
191//! ```
192//!
193//! Filter the elements to be asserted on a condition:
194//!
195//! ```
196//! use asserting::prelude::*;
197//!
198//! let subject = [1, 2, 3, 4, 5];
199//!
200//! assert_that!(subject)
201//!     .filtered_on(|e| e & 1 == 0)
202//!     .contains_exactly_in_any_order([2, 4]);
203//!
204//! let subject = ["one", "two", "three", "four"];
205//!
206//! assert_that!(subject)
207//!     .filtered_on(|e| e.len() == 5)
208//!     .single_element()
209//!     .is_equal_to("three");
210//! ```
211//!
212//! Pick the elements of a collection or an iterator at given positions:
213//!
214//! ```
215//! use asserting::prelude::*;
216//!
217//! let subject = ["one", "two", "three", "four", "five"];
218//!
219//! assert_that!(subject)
220//!     .elements_at([0, 2, 4])
221//!     .contains_exactly(["one", "three", "five"]);
222//! ```
223//!
224//! ## Soft assertions
225//!
226//! ```should_panic
227//! use asserting::prelude::*;
228//!
229//! verify_that!("the answer to all important questions is 42")
230//!     .contains("unimportant")
231//!     .has_at_most_length(41)
232//!     .soft_panic();
233//! ```
234//!
235//! executes both assertions and prints the messages of both failing
236//! assertions in the panic message:
237//!
238//! ```console
239//! expected subject to contain "unimportant"
240//!    but was: "the answer to all important questions is 42"
241//!   expected: "unimportant"
242//!
243//! expected subject to have at most a length of 41
244//!    but was: 43
245//!   expected: <= 41
246//! ```
247//!
248//! For more details see [`Spec::soft_panic()`].
249//!
250//! ## Asserting custom types
251//!
252//! We can extract a property of a custom type and assert its value:
253//!
254//! ```
255//! # use asserting::prelude::*;
256//! struct MyStruct {
257//!     important_property: String,
258//!     other_property: f64,
259//! }
260//!
261//! let some_thing = MyStruct {
262//!     important_property: "imperdiet aliqua zzril eiusmod".into(),
263//!     other_property: 99.9,
264//! };
265//!
266//! assert_that!(some_thing).extracting(|s| s.important_property)
267//!     .is_equal_to("imperdiet aliqua zzril eiusmod");
268//!
269//! ```
270//!
271//! Or we can map a custom type that does not implement a required trait to some
272//! supported type, e.g., a tuple in this example:
273//!
274//! ```
275//! # use asserting::prelude::*;
276//! struct Point {
277//!     x: i64,
278//!     y: i64,
279//! }
280//!
281//! let target = Point { x: 12, y: -64 };
282//!
283//! assert_that!(target).mapping(|s| (s.x, s.y)).is_equal_to((12, -64));
284//! ```
285//!
286//! ## Predicate as custom assertion
287//!
288//! We can use any predicate function for a custom assertion:
289//!
290//! ```
291//! # use asserting::prelude::*;
292//! fn is_odd(value: &i32) -> bool {
293//!     value & 1 == 1
294//! }
295//!
296//! assert_that!(37).satisfies_with_message("expected my number to be odd", is_odd);
297//! ```
298//!
299//! ## Assert that some code panics or does not panic
300//!
301//! Requires crate feature `panic`.
302//!
303//! ```
304//! # #[cfg(not(feature = "panic"))]
305//! # fn main() {}
306//! # #[cfg(feature = "panic")]
307//! # fn main() {
308//! use asserting::prelude::*;
309//!
310//! fn divide(a: i32, b: i32) -> i32 {
311//!     a / b
312//! }
313//!
314//! assert_that_code!(|| { divide(7, 0); }).panics();
315//!
316//! assert_that_code!(|| { divide(7, 0); })
317//!     .panics_with_message("attempt to divide by zero");
318//!
319//! assert_that_code!(|| { divide(7, 3); }).does_not_panic();
320//! # }
321//! ```
322//!
323//! # The `assert_that` and `verify_that` functions and macros
324//!
325//! Assertions can be written in two ways. The standard way that panics when
326//! an assertion fails or the alternative way that collects failures from
327//! failed assertions which can be read later.
328//!
329//! To call assertion functions on a subject, it is wrapped into the [`Spec`]
330//! struct. This can be done by calling one of the functions:
331//!
332//! * [`assert_that`] - wraps the subject into a [`Spec`] that panics if an
333//!   assertion fails
334//! * [`verify_that`] - wraps the subject into a [`Spec`] that collects failures
335//!   from assertions, which can be read later.
336//! * [`assert_that_code`] - wraps a closure into a [`Spec`] for asserting
337//!   whether the code in the closure panics or does not panic. It panics if an
338//!   assertion fails.
339//! * [`verify_that_code`] - wraps a closure into a [`Spec`] for asserting
340//!   whether the code in the closure panics or does not panic. It collects
341//!   failures from assertions, which can be read later.
342//!
343//! The [`Spec`] can hold additional information about the subject, such as the
344//! expression we are asserting, the code location of the assert statement and
345//! an optional description of what we are going to assert. These attributes are
346//! all optional and must be set explicitly by the user.
347//!
348//! For convenience, a set of macros with the same names as the functions above
349//! is provided which set the expression and the code location for the user.
350//!
351//! * [`assert_that!`] - calls the [`assert_that`] function and sets the
352//!   expression inside the macro call as the expression in the [`Spec`] as well
353//!   as the location of the macro call as the code location.
354//! * [`verify_that!`] - calls the [`verify_that`] function and sets the
355//!   expression inside the macro call as the expression in the [`Spec`] as well
356//!   as the location of the macro call as the code location.
357//! * [`assert_that_code!`] - calls the [`assert_that_code`] function and sets
358//!   the expression inside the macro call as the expression in the [`Spec`] as
359//!   well as the location of the macro call as the code location.
360//! * [`verify_that_code!`] - calls the [`verify_that_code`] function and sets
361//!   the expression inside the macro call as the expression in the [`Spec`] as
362//!   well as the location of the macro call as the code location.
363//!
364//! For example, calling the macro [`assert_that!`] like so:
365//!
366//! ```
367//! # use asserting::prelude::*;
368//! assert_that!(7 * 6).is_equal_to(42);
369//! ```
370//!
371//! is equivalent to calling the function [`assert_that`] and then calling
372//! the methods [`named()`] and [`located_at()`] on the returned [`Spec`],
373//! like so:
374//!
375//! ```
376//! # use asserting::prelude::*;
377//! assert_that(7 * 6)
378//!     .named("7 * 6")
379//!     .located_at(
380//!         Location {
381//!             file: file!(),
382//!             line: line!(),
383//!             column: column!(),
384//!         }
385//!     ).is_equal_to(42);
386//! ```
387//!
388//! When using the `verfiy_*` variants of the macros or functions for each
389//! failing assertion, a failure of type [`AssertFailure`] is added to the
390//! [`Spec`]. We can read the failures collected by calling the [`failures()`]
391//! method, like so:
392//!
393//! ```
394//! # use asserting::prelude::*;
395//! let failures = verify_that!(7 * 5).is_equal_to(42).failures();
396//!
397//! assert_that!(failures).has_length(1);
398//! ```
399//!
400//! or to get a list of formatted failure messages, we can call the
401//! [`display_failures()`] method, like so:
402//!
403//! ```
404//! # use asserting::prelude::*;
405//!
406//! let failures = verify_that!(7 * 5).is_equal_to(42).display_failures();
407//!
408//! assert_that!(failures).contains_exactly([
409//!     r"expected 7 * 5 to be equal to 42
410//!    but was: 35
411//!   expected: 42
412//! "
413//! ]);
414//! ```
415//!
416//! # Custom assertions
417//!
418//! `asserting` provides 4 ways to do custom assertions:
419//!
420//! 1. Predicate functions as custom assertions used with the [`Spec::satisfies()`] method
421//! 2. Property base assertions for any type that implements a property trait
422//! 3. Custom expectations used with the [`Spec::expecting()`] method
423//! 4. Custom assertions methods
424//!
425//! > &#x1F4A1;
426//! > Often the easiest way to assert a custom type is to write a helper
427//! > function that asserts parts (e.g., fields of a struct) using existing
428//! > assertions. See the example [`assertion_function.rs`](examples/assertion_function.rs)
429//! > which demonstrates how to use a helper function for asserting a custom
430//! > struct.
431//!
432//! How to use predicate functions as custom assertions is described on the
433//! [`Spec::satisfies()`] method and in the [Examples](#predicate-as-custom-assertion)
434//! chapter above. The other 3 ways are described in the following subchapters.
435//!
436//! ## Property-based assertions
437//!
438//! Some assertions provided by `asserting` are so-called property-based
439//! assertions. They are implemented for all types that implement a related
440//! property trait.
441//!
442//! For example, the `has_length()` assertion is implemented for all types that
443//! implement the [`LengthProperty`].
444//!
445//! If we want to provide the `has_length()` assertion for a custom type, we
446//! simply need to implement the [`LengthProperty`] trait for this type.
447//!
448//! Let's assume we have a custom struct `PathWay` and we implement the
449//! [`LengthProperty`] for `PathWay`:
450//!
451//! ```
452//! use asserting::properties::LengthProperty;
453//!
454//! #[derive(Debug)]
455//! struct PathWay {
456//!     len: usize
457//! }
458//!
459//! impl LengthProperty for PathWay {
460//!     fn length_property(&self) -> usize {
461//!         self.len
462//!     }
463//! }
464//! ```
465//!
466//! Then we can assert the length of a `PathWay` using the `has_length()`
467//! assertion:
468//!
469//! ```
470//! # use asserting::properties::LengthProperty;
471//! #
472//! # #[derive(Debug)]
473//! # struct PathWay {
474//! #    len: usize
475//! # }
476//! #
477//! # impl LengthProperty for PathWay {
478//! #     fn length_property(&self) -> usize {
479//! #         self.len
480//! #     }
481//! # }
482//! use asserting::prelude::*;
483//!
484//! let some_path = PathWay { len: 27 };
485//!
486//! assert_that!(some_path).has_length(27);
487//! ```
488//!
489//! Browse the [`properties`] module to see which property traits are available.
490//!
491//! ## Writing custom expectations
492//!
493//! A custom expectation is any type that implements the [`Expectation`] trait.
494//! For example, let's assume we have a custom type `Either` and want to write
495//! an expectation that verifies that a value of type `Either` is a left value.
496//!
497//! ```no_run
498//! use asserting::spec::{DiffFormat, Expectation, Expression, Unknown};
499//! use std::fmt::Debug;
500//!
501//! #[derive(Debug)]
502//! enum Either<L, R> {
503//!     Left(L),
504//!     Right(R),
505//! }
506//!
507//! struct IsLeft;
508//!
509//! impl<L, R> Expectation<Either<L, R>> for IsLeft
510//! where
511//!     L: Debug,
512//!     R: Debug,
513//! {
514//!     fn test(&mut self, subject: &Either<L, R>) -> bool {
515//!         match subject {
516//!             Either::Left(_) => true,
517//!             _ => false,
518//!         }
519//!     }
520//!
521//!     fn message(&self, expression: &Expression<'_>, actual: &Either<L, R>, _inverted: bool, _format: &DiffFormat) -> String {
522//!         format!(
523//!             "expected {expression} is {:?}\n   but was: {actual:?}\n  expected: {:?}",
524//!             Either::Left::<_, Unknown>(Unknown),
525//!             Either::Left::<_, Unknown>(Unknown),
526//!         )
527//!      }
528//! }
529//! ```
530//!
531//! We can now use the expectation `IsLeft` with the [`Spec::expecting()`]
532//! method:
533//!
534//! ```
535//! # use asserting::spec::{DiffFormat, Expectation, Expression, Unknown};
536//! # use std::fmt::Debug;
537//! #
538//! # #[derive(Debug)]
539//! # enum Either<L, R> {
540//! #     Left(L),
541//! #     Right(R),
542//! # }
543//! #
544//! # struct IsLeft;
545//! #
546//! # impl<L, R> Expectation<Either<L, R>> for IsLeft
547//! # where
548//! #     L: Debug,
549//! #     R: Debug,
550//! # {
551//! #     fn test(&mut self, subject: &Either<L, R>) -> bool {
552//! #         match subject {
553//! #             Either::Left(_) => true,
554//! #             _ => false,
555//! #         }
556//! #     }
557//! #
558//! #     fn message(&self, expression: &Expression<'_>, actual: &Either<L, R>, _inverted: bool, _format: &DiffFormat) -> String {
559//! #         format!(
560//! #             "expected {expression} is {:?}\n   but was: {actual:?}\n  expected: {:?}",
561//! #             Either::Left::<_, Unknown>(Unknown),
562//! #             Either::Left::<_, Unknown>(Unknown),
563//! #         )
564//! #      }
565//! # }
566//! use asserting::prelude::*;
567//!
568//! let subject: Either<String, i64> = Either::Left("left value".to_string());
569//!
570//! assert_that!(subject).expecting(IsLeft);
571//! ```
572//!
573//! ## Providing a custom assertion method
574//!
575//! In the previous chapter, we implemented a custom expectation which can be
576//! used with the [`Spec::expecting()`] method. But this way is not very
577//! expressive.
578//!
579//! Additionally, we can implement a custom assertion method via an extension
580//! trait.
581//!
582//! ```
583//! # use asserting::spec::{DiffFormat, Expectation, Expression, Unknown};
584//! #
585//! # #[derive(Debug)]
586//! # enum Either<L, R> {
587//! #     Left(L),
588//! #     Right(R),
589//! # }
590//! #
591//! # struct IsLeft;
592//! #
593//! # impl<L, R> Expectation<Either<L, R>> for IsLeft
594//! # where
595//! #     L: Debug,
596//! #     R: Debug,
597//! # {
598//! #     fn test(&mut self, subject: &Either<L, R>) -> bool {
599//! #         match subject {
600//! #             Either::Left(_) => true,
601//! #             _ => false,
602//! #         }
603//! #     }
604//! #
605//! #     fn message(&self, expression: &Expression<'_>, actual: &Either<L, R>, _inverted: bool, _format: &DiffFormat) -> String {
606//! #         format!(
607//! #             "expected {expression} is {:?}\n   but was: {actual:?}\n  expected: {:?}",
608//! #             Either::Left::<_, Unknown>(Unknown),
609//! #             Either::Left::<_, Unknown>(Unknown),
610//! #         )
611//! #      }
612//! # }
613//! use asserting::spec::{FailingStrategy, Spec};
614//! use std::fmt::Debug;
615//!
616//! pub trait AssertEither {
617//!     fn is_left(self) -> Self;
618//! }
619//!
620//! impl<L, R, Q> AssertEither for Spec<'_, Either<L, R>, Q>
621//! where
622//!     L: Debug,
623//!     R: Debug,
624//!     Q: FailingStrategy,
625//! {
626//!     fn is_left(self) -> Self {
627//!         self.expecting(IsLeft)
628//!     }
629//! }
630//! ```
631//!
632//! Now we can use the assertion method `is_left()` for asserting whether a
633//! subject of type `Either` is a left value.
634//!
635//! ```
636//! # use asserting::spec::{DiffFormat, Expectation, Expression, Unknown};
637//! # use std::fmt::Debug;
638//! #
639//! # #[derive(Debug)]
640//! # enum Either<L, R> {
641//! #     Left(L),
642//! #     Right(R),
643//! # }
644//! #
645//! # struct IsLeft;
646//! #
647//! # impl<L, R> Expectation<Either<L, R>> for IsLeft
648//! # where
649//! #     L: Debug,
650//! #     R: Debug,
651//! # {
652//! #     fn test(&mut self, subject: &Either<L, R>) -> bool {
653//! #         match subject {
654//! #             Either::Left(_) => true,
655//! #             _ => false,
656//! #         }
657//! #     }
658//! #
659//! #     fn message(&self, expression: &Expression<'_>, actual: &Either<L, R>, _inverted: bool, _format: &DiffFormat) -> String {
660//! #         format!(
661//! #             "expected {expression} is {:?}\n   but was: {actual:?}\n  expected: {:?}",
662//! #             Either::Left::<_, Unknown>(Unknown),
663//! #             Either::Left::<_, Unknown>(Unknown),
664//! #         )
665//! #      }
666//! # }
667//! # use asserting::spec::{FailingStrategy, Spec};
668//! #
669//! # pub trait AssertEither {
670//! #     fn is_left(self) -> Self;
671//! # }
672//! #
673//! # impl<L, R, Q> AssertEither for Spec<'_, Either<L, R>, Q>
674//! # where
675//! #     L: Debug,
676//! #     R: Debug,
677//! #     Q: FailingStrategy,
678//! # {
679//! #     fn is_left(self) -> Self {
680//! #         self.expecting(IsLeft)
681//! #     }
682//! # }
683//! use asserting::prelude::*;
684//!
685//! let subject: Either<String, i64> = Either::Left("left value".to_string());
686//!
687//! assert_that!(subject).is_left();
688//! ```
689//!
690//! [`AssertElements`]: assertions::AssertElements
691//! [`AssertFailure`]: spec::AssertFailure
692//! [`Expectation`]: spec::Expectation
693//! [`LengthProperty`]: properties::LengthProperty
694//! [`Spec`]: spec::Spec
695//! [`Spec::each_element()`]: spec::Spec::each_element
696//! [`Spec::expecting()`]: spec::Spec::expecting
697//! [`Spec::satisfies()`]: spec::Spec::satisfies
698//! [`Spec::soft_panic()`]: spec::Spec::soft_panic
699//! [`assert_that`]: spec::assert_that
700//! [`assert_that_code`]: spec::assert_that_code
701//! [`verify_that`]: spec::verify_that
702//! [`verify_that_code`]: spec::verify_that_code
703//! [`display_failures()`]: spec::Spec::display_failures
704//! [`failures()`]: spec::Spec::failures
705//! [`named()`]: spec::Spec::named
706//! [`located_at()`]: spec::Spec::located_at
707
708#![doc(html_root_url = "https://docs.rs/asserting/0.12.0")]
709#![cfg_attr(not(feature = "std"), no_std)]
710// Render feature requirements in docs.rs
711#![cfg_attr(docsrs, feature(doc_cfg))]
712
713#[cfg(not(feature = "std"))]
714#[allow(unused_imports)]
715mod std {
716    extern crate alloc;
717    pub use alloc::*;
718    pub use core::*;
719
720    pub mod borrow {
721        extern crate alloc;
722        pub use alloc::borrow::*;
723        pub use core::borrow::*;
724    }
725
726    pub mod fmt {
727        extern crate alloc;
728        pub use alloc::fmt::*;
729        pub use core::fmt::*;
730    }
731
732    pub mod slice {
733        extern crate alloc;
734        pub use alloc::slice::*;
735        pub use core::slice::*;
736    }
737
738    pub mod str {
739        extern crate alloc;
740        pub use alloc::str::*;
741        pub use core::str::*;
742    }
743
744    pub mod sync {
745        extern crate alloc;
746        pub use alloc::sync::*;
747        pub use core::sync::*;
748    }
749
750    pub mod ffi {
751        extern crate alloc;
752        pub use alloc::ffi::*;
753        pub use core::ffi::*;
754    }
755}
756
757#[cfg(feature = "std")]
758mod std {
759    pub use std::*;
760}
761
762pub mod assertions;
763pub mod colored;
764pub mod expectations;
765pub mod prelude;
766pub mod properties;
767pub mod spec;
768
769#[cfg(feature = "bigdecimal")]
770mod bigdecimal;
771mod boolean;
772mod c_string;
773mod char;
774mod char_count;
775mod collection;
776#[cfg(feature = "std")]
777mod env;
778mod equality;
779mod error;
780mod expectation_combinators;
781mod float;
782mod integer;
783mod iterator;
784mod length;
785mod map;
786#[cfg(feature = "num-bigint")]
787mod num_bigint;
788mod number;
789mod option;
790mod order;
791#[cfg(feature = "std")]
792mod os_sting;
793#[cfg(feature = "panic")]
794mod panic;
795mod predicate;
796mod range;
797mod result;
798#[cfg(feature = "rust-decimal")]
799mod rust_decimal;
800mod slice;
801mod string;
802mod vec;
803
804// test code snippets in the README.md
805#[cfg(doctest)]
806#[doc = include_str!("../README.md")]
807#[allow(dead_code)]
808type TestCodeSnippetsInReadme = ();
809
810// workaround for false positive 'unused extern crate' warnings until
811// Rust issue [#95513](https://github.com/rust-lang/rust/issues/95513) is fixed
812#[cfg(test)]
813mod dummy_extern_uses {
814    use fakeenv as _;
815    use proptest as _;
816    use time as _;
817    use version_sync as _;
818}