1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
#![deny(clippy::all)] #![deny(clippy::pedantic)] #![deny(clippy::nursery)] #![deny(clippy::cargo)] #![deny(missing_docs)] // ============================================================== #![allow(clippy::module_name_repetitions)] #![allow(clippy::items_after_statements)] // ============================================================== #![doc(html_root_url = "https://docs.rs/macrofied-toolbox/0.1.0")] //! This library provides an ergonomic experience of adding debugging messages to rust's //! `Result<T,E>` and `Option<T>` patterns //! //! Just like the [`cli-toolbox`](https://crates.io/crates/cli-toolbox) crate, that the debug logic //! is based on, this is not a logging alternative; it's intended to produce debugging output to be //! used during application development. //! //! Although the macros were designed to make debugging more ergonomic, they include variations that //! do not include debugging to provide coding consistency, so you have the option use the same syntax //! consistently throughout your crate. //! //! ### `Result<T,E>` //! ```no_run //! use std::fs::File; //! use std::io; //! use std::io::{BufWriter, Write}; //! //! use macrofied_toolbox::result; //! //! #[cfg(debug_assertions)] //! use cli_toolbox::debug; //! //! fn main() -> io::Result<()> { //! let file_name = "foo.txt"; //! //! // attempts to create a file //! result! { //! WHEN File::create(file_name); //! // if the file is successfully created, write some content //! OK file; { //! let mut out = BufWriter::new(file); //! //! writeln!(out, "some content")?; //! writeln!(out, "some more content")?; //! } //! // if an exception occurs output debug message to stderr //! DEBUG "problem creating file: {:?}", file_name //! //! // * debug messages are conditionally compiled //! // and do not output anything in release builds //! // * exceptions are appended to the debug message //! }; //! //! Ok(()) //! } //! ``` //! //! ### `Option<T>` //! //! ```text //! . //! . //! . //! ``` //! //! \* _the macros are automatically generated with custom build scripts, including their_ `docs` and `tests` #[cfg(feature = "result")] mod result; #[cfg(test)] mod tests;