Avatar ·

Rust में संकलन त्रुटि उत्पन्न करने वाले विस्तारित मैक्रो को कैसे देखें?

मैं Rust में नया हूँ और कोड जनरेट करने के लिए मैक्रोज़ का उपयोग करने का प्रयास कर रहा हूँ। मैंने लोकप्रिय क्रेट `serde` लिया और यह कोड लिखा:\n\n```rust\nuse serde::{Serialize, Deserialize};\n\n#[derive(Serialize, Deserialize)]\nstruct User {\n name: String,\n age: u32,\n email: String,\n}\n\nfn main() {\n let user = User {\n name: "Alice".to_string(),\n age: 30,\n email: "alice@example.com".to_string(),\n };\n\n let json = serde_json::to_string(&user).unwrap();\n println!("{}", json);\n}\n```\n\nयह काम करता है। लेकिन जब मैंने ट्रेट के स्वचालित कार्यान्वयन के लिए अपना खुद का मैक्रो लिखने का प्रयास किया:\n\n```rust\nmacro_rules! impl_display {\n ($type:ty, $format:expr) => {\n impl std::fmt::Display for $type {\n fn fmt(&self, f: &mut std::fmt::Formatte