{"id":17835694,"url":"https://github.com/rob2309/derive-debug","last_synced_at":"2025-03-19T16:31:05.544Z","repository":{"id":65347666,"uuid":"589991992","full_name":"Rob2309/derive-debug","owner":"Rob2309","description":null,"archived":false,"fork":false,"pushed_at":"2023-01-20T13:28:43.000Z","size":15,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-17T09:04:42.208Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Rob2309.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2023-01-17T12:22:05.000Z","updated_at":"2024-02-20T07:29:41.000Z","dependencies_parsed_at":"2023-02-12T02:30:45.635Z","dependency_job_id":null,"html_url":"https://github.com/Rob2309/derive-debug","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rob2309%2Fderive-debug","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rob2309%2Fderive-debug/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rob2309%2Fderive-debug/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rob2309%2Fderive-debug/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Rob2309","download_url":"https://codeload.github.com/Rob2309/derive-debug/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244463680,"owners_count":20456925,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-27T20:24:25.162Z","updated_at":"2025-03-19T16:31:05.236Z","avatar_url":"https://github.com/Rob2309.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# derive-debug\n\nThis crate implements a more customizable version of `#[derive(Debug)]`.\n\n# Usage\nThe usage is very similar to `#[derive(Debug)]` with a few extra customization options.\n\n## Deriving a struct\n```rust\nuse derive_debug::Dbg;\n\n#[derive(Dbg)]\nstruct Foo {\n    field_a: u32,\n    #[dbg(placeholder = \"...\")]\n    field_b: Vec\u003cu32\u003e, // will be printed as \"field_b: ...\"\n    #[dbg(skip)]\n    field_c: bool, // will be left out\n    #[dbg(alias = \"my_string\")]\n    field_d: u32, // will be printed as \"my_string: 42\"\n    #[dbg(fmt = \"{:#06X}\")]\n    field_e: u32, // will be printed with the specified format\n}\n```\n\n# Deriving an enum\n```rust\nuse derive_debug::Dbg;\n\n#[derive(Dbg)]\nenum Foo {\n    VariantA(u32, u32, u32),\n    #[dbg(skip)]\n    VariantB{a: u32, b: bool}, // Will be printed as \"VariantB\"\n\n    // same options available as for struct fields\n    VariantC{a: u32, #[dbg(placeholder = \"...\")] b: bool}\n}\n```\n\n## Detailed options\n### Field Options\n- `#[dbg(skip)]` completely omits a field in the output\n```rust\n    use derive_debug::Dbg;\n\n    #[derive(Dbg)]\n    struct Foo {\n        field_a: bool,\n        #[dbg(skip)]\n        field_b: u32,\n    }\n\n    // Outputs: Foo { field_a: true }\n```\n- `#[dbg(placeholder = \"xyz\")]` will print `xyz` instead of the actual contents of a field\n```rust\n    use derive_debug::Dbg;\n\n    #[derive(Dbg)]\n    struct Foo {\n        field_a: bool,\n        #[dbg(placeholder = \"...\")]\n        field_b: u32,\n    }\n\n    // Outputs: Foo { field_a: true, field_b: ... }\n```\n- `#[dbg(alias = \"some_alias\")]` will print `some_alias` as field name instead of the real name\n```rust\n    use derive_debug::Dbg;\n\n    #[derive(Dbg)]\n    struct Foo {\n        field_a: bool,\n        #[dbg(alias=\"not_field_b\")]\n        field_b: u32,\n    }\n\n    // Outputs: Foo { field_a: true, not_field_b: 42 }\n```\n- `#[dbg(fmt = \"{:#06X}\")]` will print the field with the specified format\n```rust\n    use derive_debug::Dbg;\n\n    #[derive(Dbg)]\n    struct Foo {\n        field_a: bool,\n        #[dbg(fmt = \"{:#06X}\")]\n        field_b: u32,\n    }\n\n    // Outputs: Foo { field_a: true, field_b: 0x002A }\n```\n- `#[dbg(formatter = \"my_func\")]` will print the field using the specified function.  \nThe function has to return a type that can be formatted using \"{}\"\n```rust\n    use derive_debug::Dbg;\n\n    #[derive(Dbg)]\n    struct Foo(u32, #[dbg(formatter = \"fmt_not_zero\")] u32);\n\n    fn fmt_not_zero(v: \u0026u32) -\u003e \u0026'static str {\n        if *v == 0 {\n            \"0\"\n        } else {\n            \"not 0\"\n        }\n    }\n\n    // Outputs: Foo(42, not 0)\n```\n\n### Enum Variant Options\n- `#[dbg(skip)]` only prints the name of the variant and omits its contents\n```rust\n    use derive_debug::Dbg;\n\n    #[derive(Dbg)]\n    enum Foo {\n        #[dbg(skip)]\n        SomeVariant{a: bool, b: u32},\n    }\n\n    // Outputs: SomeVariant\n```\n- `#[dbg(alias = \"some_alias\")]` will use `some_alias` as variant name instead of the real name\n```rust\n    use derive_debug::Dbg;\n\n    #[derive(Dbg)]\n    enum Foo {\n        #[dbg(alias = \"NotSomeVariant\")]\n        SomeVariant{a: bool, b: u32},\n    }\n\n    // Outputs: NotSomeVariant { a: true, b: 42 }\n```\n\n### struct Options\n- `#[dbg(alias = \"MyAlias\")]` will use `MyAlias` as struct name instead of the real name\n```rust\n    use derive_debug::Dbg;\n\n    #[derive(Dbg)]\n    #[dbg(alias = \"NotFoo\")]\n    struct Foo {\n        field_a: bool,\n        field_b: u32,\n    }\n\n    // Outputs: NotFoo { field_a: true, not_field_b: 42 }\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frob2309%2Fderive-debug","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frob2309%2Fderive-debug","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frob2309%2Fderive-debug/lists"}