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
76
77
78
79
80
/// Defines `dbg` macro that prints and returns the value
/// of a given expression for quick and dirty debugging.
///
/// The implementation of the generated `dbg`-like macro
/// is based on [`std::dbg`] macro implementation,
/// but the exact output printed by [`std::dbg`]
/// should not be relied upon and is subject to future changes.
///
/// The first argument specifies the generated macro name.
/// The writer itself is specified by the rest arguments with the [`define_writer`] macros.
///
/// Use [`define_try_dbg`] if you need to define a fallible dbg macros.
///
/// # Examples
///
/// let mut string = String::new();
/// custom_print::define_dbg!(cdbg, concat, |value: &str| string += value);
///
/// assert_eq!(cdbg!("value"), "value");
/// assert!(string.contains("\"value\""));
/// ```
///
/// [`define_writer`]: macro.define_writer.html
/// [`define_try_dbg`]: macro.define_try_dbg.html
/// Defines `try_dbg` macro that prints and returns the value
/// of a given expression wrapped in for quick and dirty debugging
/// or return an error if write failed.
///
/// The implementation of the generated `dbg`-like macro
/// is based on [`std::dbg`] macro implementation,
/// but the exact output printed by [`std::dbg`]
/// should not be relied upon and is subject to future changes.
///
/// The first argument specifies the generated macro name.
/// The writer itself is specified by the rest arguments with the [`define_writer`] macros.
///
/// Use [`define_dbg`] if you need to define a non-fallible dbg macros.
///
/// # Examples
///
/// let mut string = String::new();
/// custom_print::define_try_dbg!(try_dbg, concat, |value: &str| string += value);
///
/// assert_eq!(try_dbg!("value"), Ok("value"));
/// assert!(string.contains("\"value\""));
/// ```
///
/// [`define_writer`]: macro.define_writer.html
/// [`define_dbg`]: macro.define_dbg.html