| 1 | use formatxrust-analyzer cargo formatx 0.2.4 crate/::formatxrust-analyzer cargo formatx 0.2.4 macros/formatx!; |
| 2 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display#; |
| 3 | |
| 4 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)] |
| 5 | struct Foorust-analyzer cargo formatx 0.2.4 Foo# { |
| 6 | _barrust-analyzer cargo formatx 0.2.4 Foo#_bar.: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, |
| 7 | } |
| 8 | |
| 9 | impl Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# for Foorust-analyzer cargo formatx 0.2.4 Foo# { |
| 10 | fn fmtrust-analyzer cargo formatx 0.2.4 impl#[Foo][Display]fmt().(&self, f: &mut stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#<'_>) -> stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# { |
| 11 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "{:?}", self) |
| 12 | } |
| 13 | } |
| 14 | |
| 15 | fn mainrust-analyzer cargo formatx 0.2.4 main().() { |
| 16 | let foo = Foorust-analyzer cargo formatx 0.2.4 Foo# { |
| 17 | _barrust-analyzer cargo formatx 0.2.4 Foo#_bar.: "foo-bar-struct".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().(), |
| 18 | }; |
| 19 | |
| 20 | printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("{}", formatxrust-analyzer cargo formatx 0.2.4 macros/formatx!!("{:#?}", foo).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()); |
| 21 | } |