#[derive(CustomDebug)]
{
// Attributes available to this derive:
#[debug]
}
Expand description
A procedural macro that implements the std::fmt::Debug
trait for a type,
with support for the #[debug(skip)]
attribute to skip specific fields.
This macro derives a custom Debug implementation that behaves like the standard
library’s Debug derive, but allows individual fields to be excluded from the
debug output by annotating them with #[debug(skip)]
.
§Supported Attributes
#[debug(skip)]
: Excludes the field from the debug output
§Examples
§Struct Example
use lombok_macros::*;
#[derive(CustomDebug)]
struct User {
name: String,
#[debug(skip)]
password: String,
email: String,
}
let user = User {
name: "Alice".to_string(),
password: "secret123".to_string(),
email: "alice@example.com".to_string(),
};
println!("{:?}", user);
// Output: User { name: "Alice", email: "alice@example.com" }
§Enum Example
use lombok_macros::*;
#[derive(CustomDebug)]
enum Response {
Success { data: String },
Error {
message: String,
#[debug(skip)]
internal_code: u32,
},
}
§Parameters
input
: The input token stream representing the Rust item (struct, enum, etc.) for which the Debug implementation will be generated.
§Returns
TokenStream
: The generatedstd::fmt::Debug
implementation for the type that respects the#[debug(skip)]
attribute.