| 1 | use colored_jsonrust-analyzer cargo colored_json 5.0.0 crate/::*; |
| 2 | use serde_jsonrust-analyzer cargo serde_json 1.0.85 crate/::jsonrust-analyzer cargo serde_json 1.0.85 macros/json!; |
| 3 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std error/::Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error#; |
| 4 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#; |
| 5 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#; |
| 6 | |
| 7 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 8 | fn test_display_json_valuerust-analyzer cargo colored_json 5.0.0 test_display_json_value().() -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error#>> { |
| 9 | let data = jsonrust-analyzer cargo serde_json 1.0.85 macros/json!!({ |
| 10 | "name": "John Doe", |
| 11 | "age": 43, |
| 12 | "phones": [ |
| 13 | "+44 1234567", |
| 14 | "+44 2345678" |
| 15 | ] |
| 16 | }); |
| 17 | |
| 18 | let s = to_colored_json_autorust-analyzer cargo colored_json 5.0.0 to_colored_json_auto().(&data)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 19 | printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("\n{}", s); |
| 20 | |
| 21 | return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()); |
| 22 | } |
| 23 | |
| 24 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 25 | fn test_traitrust-analyzer cargo colored_json 5.0.0 test_trait().() -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error#>> { |
| 26 | printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!( |
| 27 | "\n{}", |
| 28 | r#"{ |
| 29 | "array": [ |
| 30 | "ele1", |
| 31 | "ele2" |
| 32 | ], |
| 33 | "float": 3.1415926, |
| 34 | "integer": 4398798674962568, |
| 35 | "string": "string" |
| 36 | } |
| 37 | "# |
| 38 | .to_colored_json_autorust-analyzer cargo colored_json 5.0.0 impl#[S][ToColoredJson]to_colored_json_auto().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). |
| 39 | ); |
| 40 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 41 | } |
| 42 | |
| 43 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 44 | fn test_trait_errrust-analyzer cargo colored_json 5.0.0 test_trait_err().() -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error#>> { |
| 45 | eprintlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/eprintln!!( |
| 46 | "\n{}", |
| 47 | r#"{ |
| 48 | "array": [ |
| 49 | "ele1", |
| 50 | "ele2" |
| 51 | ], |
| 52 | "float": 3.1415926, |
| 53 | "integer": 4398798674962568, |
| 54 | "string": "string" |
| 55 | } |
| 56 | "# |
| 57 | .to_colored_jsonrust-analyzer cargo colored_json 5.0.0 impl#[S][ToColoredJson]to_colored_json().(ColorModerust-analyzer cargo colored_json 5.0.0 ColorMode#::Autorust-analyzer cargo colored_json 5.0.0 ColorMode#Auto#(Outputrust-analyzer cargo colored_json 5.0.0 Output#::StdErrrust-analyzer cargo colored_json 5.0.0 Output#StdErr#))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). |
| 58 | ); |
| 59 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 60 | } |
| 61 | |
| 62 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 63 | fn test_trait_color_offrust-analyzer cargo colored_json 5.0.0 test_trait_color_off().() -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error#>> { |
| 64 | printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!( |
| 65 | "\n{}", |
| 66 | r#"{ |
| 67 | "array": [ |
| 68 | "ele1", |
| 69 | "ele2" |
| 70 | ], |
| 71 | "float": 3.1415926, |
| 72 | "integer": 4398798674962568, |
| 73 | "string": "string" |
| 74 | } |
| 75 | "# |
| 76 | .to_colored_jsonrust-analyzer cargo colored_json 5.0.0 impl#[S][ToColoredJson]to_colored_json().(ColorModerust-analyzer cargo colored_json 5.0.0 ColorMode#::Offrust-analyzer cargo colored_json 5.0.0 ColorMode#Off#)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). |
| 77 | ); |
| 78 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 79 | } |
| 80 | |
| 81 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 82 | fn test_trait_stylerrust-analyzer cargo colored_json 5.0.0 test_trait_styler().() -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error#>> { |
| 83 | printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!( |
| 84 | "\n{}", |
| 85 | r#"{ |
| 86 | "array": [ |
| 87 | "ele1", |
| 88 | "ele2" |
| 89 | ], |
| 90 | "float": 3.1415926, |
| 91 | "integer": 4398798674962568, |
| 92 | "string": "string" |
| 93 | } |
| 94 | "# |
| 95 | .to_colored_json_with_stylerrust-analyzer cargo colored_json 5.0.0 impl#[S][ToColoredJson]to_colored_json_with_styler().( |
| 96 | ColorModerust-analyzer cargo colored_json 5.0.0 ColorMode#::defaultrust-analyzer cargo colored_json 5.0.0 impl#[ColorMode][Default]default().().evalrust-analyzer cargo colored_json 5.0.0 impl#[ColorMode]eval().(), |
| 97 | Stylerrust-analyzer cargo colored_json 5.0.0 Styler# { |
| 98 | keyrust-analyzer cargo colored_json 5.0.0 Styler#key.: Colorrust-analyzer cargo yansi 1.0.1 color/Color#::Greenrust-analyzer cargo yansi 1.0.1 color/Color#Green#.foregroundrust-analyzer cargo yansi 1.0.1 color/impl#[Color]foreground().(), |
| 99 | string_valuerust-analyzer cargo colored_json 5.0.0 Styler#string_value.: Colorrust-analyzer cargo yansi 1.0.1 color/Color#::Bluerust-analyzer cargo yansi 1.0.1 color/Color#Blue#.boldrust-analyzer cargo yansi 1.0.1 color/impl#[Color]bold().(), |
| 100 | integer_valuerust-analyzer cargo colored_json 5.0.0 Styler#integer_value.: Colorrust-analyzer cargo yansi 1.0.1 color/Color#::Magentarust-analyzer cargo yansi 1.0.1 color/Color#Magenta#.boldrust-analyzer cargo yansi 1.0.1 color/impl#[Color]bold().(), |
| 101 | float_valuerust-analyzer cargo colored_json 5.0.0 Styler#float_value.: Colorrust-analyzer cargo yansi 1.0.1 color/Color#::Magentarust-analyzer cargo yansi 1.0.1 color/Color#Magenta#.italicrust-analyzer cargo yansi 1.0.1 color/impl#[Color]italic().(), |
| 102 | object_bracketsrust-analyzer cargo colored_json 5.0.0 Styler#object_brackets.: Colorrust-analyzer cargo yansi 1.0.1 color/Color#::Yellowrust-analyzer cargo yansi 1.0.1 color/Color#Yellow#.boldrust-analyzer cargo yansi 1.0.1 color/impl#[Color]bold().(), |
| 103 | array_bracketsrust-analyzer cargo colored_json 5.0.0 Styler#array_brackets.: Colorrust-analyzer cargo yansi 1.0.1 color/Color#::Cyanrust-analyzer cargo yansi 1.0.1 color/Color#Cyan#.boldrust-analyzer cargo yansi 1.0.1 color/impl#[Color]bold().(), |
| 104 | ..Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#::defaultrust-analyzer cargo colored_json 5.0.0 impl#[Styler][Default]default().() |
| 105 | }, |
| 106 | )?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). |
| 107 | ); |
| 108 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 109 | } |
| 110 | |
| 111 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 112 | fn test_trait_styler_color_offrust-analyzer cargo colored_json 5.0.0 test_trait_styler_color_off().() -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error#>> { |
| 113 | printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!( |
| 114 | "\n{}", |
| 115 | r#"{ |
| 116 | "array": [ |
| 117 | "ele1", |
| 118 | "ele2" |
| 119 | ], |
| 120 | "float": 3.1415926, |
| 121 | "integer": 4398798674962568, |
| 122 | "string": "string" |
| 123 | } |
| 124 | "# |
| 125 | .to_colored_json_with_stylerrust-analyzer cargo colored_json 5.0.0 impl#[S][ToColoredJson]to_colored_json_with_styler().( |
| 126 | ColorModerust-analyzer cargo colored_json 5.0.0 ColorMode#::Offrust-analyzer cargo colored_json 5.0.0 ColorMode#Off#, |
| 127 | Stylerrust-analyzer cargo colored_json 5.0.0 Styler# { |
| 128 | keyrust-analyzer cargo colored_json 5.0.0 Styler#key.: Colorrust-analyzer cargo yansi 1.0.1 color/Color#::Greenrust-analyzer cargo yansi 1.0.1 color/Color#Green#.foregroundrust-analyzer cargo yansi 1.0.1 color/impl#[Color]foreground().(), |
| 129 | string_valuerust-analyzer cargo colored_json 5.0.0 Styler#string_value.: Colorrust-analyzer cargo yansi 1.0.1 color/Color#::Bluerust-analyzer cargo yansi 1.0.1 color/Color#Blue#.boldrust-analyzer cargo yansi 1.0.1 color/impl#[Color]bold().(), |
| 130 | integer_valuerust-analyzer cargo colored_json 5.0.0 Styler#integer_value.: Colorrust-analyzer cargo yansi 1.0.1 color/Color#::Magentarust-analyzer cargo yansi 1.0.1 color/Color#Magenta#.boldrust-analyzer cargo yansi 1.0.1 color/impl#[Color]bold().(), |
| 131 | float_valuerust-analyzer cargo colored_json 5.0.0 Styler#float_value.: Colorrust-analyzer cargo yansi 1.0.1 color/Color#::Magentarust-analyzer cargo yansi 1.0.1 color/Color#Magenta#.italicrust-analyzer cargo yansi 1.0.1 color/impl#[Color]italic().(), |
| 132 | object_bracketsrust-analyzer cargo colored_json 5.0.0 Styler#object_brackets.: Colorrust-analyzer cargo yansi 1.0.1 color/Color#::Yellowrust-analyzer cargo yansi 1.0.1 color/Color#Yellow#.boldrust-analyzer cargo yansi 1.0.1 color/impl#[Color]bold().(), |
| 133 | array_bracketsrust-analyzer cargo colored_json 5.0.0 Styler#array_brackets.: Colorrust-analyzer cargo yansi 1.0.1 color/Color#::Cyanrust-analyzer cargo yansi 1.0.1 color/Color#Cyan#.boldrust-analyzer cargo yansi 1.0.1 color/impl#[Color]bold().(), |
| 134 | ..Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#::defaultrust-analyzer cargo colored_json 5.0.0 impl#[Styler][Default]default().() |
| 135 | }, |
| 136 | )?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). |
| 137 | ); |
| 138 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 139 | } |
| 140 | |
| 141 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 142 | fn test_writerrust-analyzer cargo colored_json 5.0.0 test_writer().() -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error#>> { |
| 143 | let data = jsonrust-analyzer cargo serde_json 1.0.85 macros/json!!({ |
| 144 | "name": "John Doe", |
| 145 | "age": 43, |
| 146 | "phones": [ |
| 147 | "+44 1234567", |
| 148 | "+44 2345678" |
| 149 | ] |
| 150 | }); |
| 151 | |
| 152 | let mut writer: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8> = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::with_capacityrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]with_capacity().(128); |
| 153 | writer.write_allrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/impls/impl#[`Vec<u8, A>`][Write]write_all().(b"\n")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 154 | write_colored_jsonrust-analyzer cargo colored_json 5.0.0 write_colored_json().(&data, &mut writer)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 155 | writer.write_allrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/impls/impl#[`Vec<u8, A>`][Write]write_all().(b"\n")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 156 | let s = unsafe { Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::from_utf8_uncheckedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]from_utf8_unchecked().(writer) }; |
| 157 | printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("{}", s); |
| 158 | return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()); |
| 159 | } |
| 160 | |
| 161 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 162 | fn test_stylerrust-analyzer cargo colored_json 5.0.0 test_styler().() -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error#>> { |
| 163 | let f = ColoredFormatterrust-analyzer cargo colored_json 5.0.0 ColoredFormatter#::with_stylerrust-analyzer cargo colored_json 5.0.0 impl#[`ColoredFormatter<F>`]with_styler().( |
| 164 | PrettyFormatterrust-analyzer cargo serde_json 1.0.85 ser/PrettyFormatter#::newrust-analyzer cargo serde_json 1.0.85 ser/impl#[`PrettyFormatter<'a>`]new().(), |
| 165 | Stylerrust-analyzer cargo colored_json 5.0.0 Styler# { |
| 166 | keyrust-analyzer cargo colored_json 5.0.0 Styler#key.: Colorrust-analyzer cargo yansi 1.0.1 color/Color#::Greenrust-analyzer cargo yansi 1.0.1 color/Color#Green#.foregroundrust-analyzer cargo yansi 1.0.1 color/impl#[Color]foreground().(), |
| 167 | string_valuerust-analyzer cargo colored_json 5.0.0 Styler#string_value.: Colorrust-analyzer cargo yansi 1.0.1 color/Color#::Bluerust-analyzer cargo yansi 1.0.1 color/Color#Blue#.boldrust-analyzer cargo yansi 1.0.1 color/impl#[Color]bold().(), |
| 168 | integer_valuerust-analyzer cargo colored_json 5.0.0 Styler#integer_value.: Colorrust-analyzer cargo yansi 1.0.1 color/Color#::Magentarust-analyzer cargo yansi 1.0.1 color/Color#Magenta#.boldrust-analyzer cargo yansi 1.0.1 color/impl#[Color]bold().(), |
| 169 | float_valuerust-analyzer cargo colored_json 5.0.0 Styler#float_value.: Colorrust-analyzer cargo yansi 1.0.1 color/Color#::Magentarust-analyzer cargo yansi 1.0.1 color/Color#Magenta#.italicrust-analyzer cargo yansi 1.0.1 color/impl#[Color]italic().(), |
| 170 | object_bracketsrust-analyzer cargo colored_json 5.0.0 Styler#object_brackets.: Colorrust-analyzer cargo yansi 1.0.1 color/Color#::Yellowrust-analyzer cargo yansi 1.0.1 color/Color#Yellow#.boldrust-analyzer cargo yansi 1.0.1 color/impl#[Color]bold().(), |
| 171 | array_bracketsrust-analyzer cargo colored_json 5.0.0 Styler#array_brackets.: Colorrust-analyzer cargo yansi 1.0.1 color/Color#::Cyanrust-analyzer cargo yansi 1.0.1 color/Color#Cyan#.boldrust-analyzer cargo yansi 1.0.1 color/impl#[Color]bold().(), |
| 172 | ..Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#::defaultrust-analyzer cargo colored_json 5.0.0 impl#[Styler][Default]default().() |
| 173 | }, |
| 174 | ); |
| 175 | |
| 176 | printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!( |
| 177 | "\n{}", |
| 178 | f.clonerust-analyzer cargo colored_json 5.0.0 impl#[`ColoredFormatter<F>`][Clone]clone().().to_colored_json_autorust-analyzer cargo colored_json 5.0.0 impl#[`ColoredFormatter<F>`]to_colored_json_auto().(&jsonrust-analyzer cargo serde_json 1.0.85 macros/json!!({ |
| 179 | "string": "string", |
| 180 | "integer": 4398798674962568u64, |
| 181 | "float": 3.1415926, |
| 182 | "array": [ |
| 183 | "ele1", |
| 184 | "ele2" |
| 185 | ] |
| 186 | }))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). |
| 187 | ); |
| 188 | |
| 189 | printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!( |
| 190 | "{}", |
| 191 | f.to_colored_json_autorust-analyzer cargo colored_json 5.0.0 impl#[`ColoredFormatter<F>`]to_colored_json_auto().(&jsonrust-analyzer cargo serde_json 1.0.85 macros/json!!({ |
| 192 | "name":"John", "age":31, "city":"New York" |
| 193 | }))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). |
| 194 | ); |
| 195 | |
| 196 | return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()); |
| 197 | } |
| 198 | |
| 199 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 200 | fn test_styler_no_colorrust-analyzer cargo colored_json 5.0.0 test_styler_no_color().() -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error#>> { |
| 201 | let f = ColoredFormatterrust-analyzer cargo colored_json 5.0.0 ColoredFormatter#::with_stylerrust-analyzer cargo colored_json 5.0.0 impl#[`ColoredFormatter<F>`]with_styler().( |
| 202 | PrettyFormatterrust-analyzer cargo serde_json 1.0.85 ser/PrettyFormatter#::newrust-analyzer cargo serde_json 1.0.85 ser/impl#[`PrettyFormatter<'a>`]new().(), |
| 203 | Stylerrust-analyzer cargo colored_json 5.0.0 Styler# { |
| 204 | keyrust-analyzer cargo colored_json 5.0.0 Styler#key.: Colorrust-analyzer cargo yansi 1.0.1 color/Color#::Greenrust-analyzer cargo yansi 1.0.1 color/Color#Green#.foregroundrust-analyzer cargo yansi 1.0.1 color/impl#[Color]foreground().(), |
| 205 | string_valuerust-analyzer cargo colored_json 5.0.0 Styler#string_value.: Colorrust-analyzer cargo yansi 1.0.1 color/Color#::Bluerust-analyzer cargo yansi 1.0.1 color/Color#Blue#.boldrust-analyzer cargo yansi 1.0.1 color/impl#[Color]bold().(), |
| 206 | integer_valuerust-analyzer cargo colored_json 5.0.0 Styler#integer_value.: Colorrust-analyzer cargo yansi 1.0.1 color/Color#::Magentarust-analyzer cargo yansi 1.0.1 color/Color#Magenta#.boldrust-analyzer cargo yansi 1.0.1 color/impl#[Color]bold().(), |
| 207 | float_valuerust-analyzer cargo colored_json 5.0.0 Styler#float_value.: Colorrust-analyzer cargo yansi 1.0.1 color/Color#::Magentarust-analyzer cargo yansi 1.0.1 color/Color#Magenta#.italicrust-analyzer cargo yansi 1.0.1 color/impl#[Color]italic().(), |
| 208 | object_bracketsrust-analyzer cargo colored_json 5.0.0 Styler#object_brackets.: Colorrust-analyzer cargo yansi 1.0.1 color/Color#::Yellowrust-analyzer cargo yansi 1.0.1 color/Color#Yellow#.boldrust-analyzer cargo yansi 1.0.1 color/impl#[Color]bold().(), |
| 209 | array_bracketsrust-analyzer cargo colored_json 5.0.0 Styler#array_brackets.: Colorrust-analyzer cargo yansi 1.0.1 color/Color#::Cyanrust-analyzer cargo yansi 1.0.1 color/Color#Cyan#.boldrust-analyzer cargo yansi 1.0.1 color/impl#[Color]bold().(), |
| 210 | ..Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#::defaultrust-analyzer cargo colored_json 5.0.0 impl#[Styler][Default]default().() |
| 211 | }, |
| 212 | ); |
| 213 | |
| 214 | printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!( |
| 215 | "\n{}", |
| 216 | f.clonerust-analyzer cargo colored_json 5.0.0 impl#[`ColoredFormatter<F>`][Clone]clone().().to_colored_jsonrust-analyzer cargo colored_json 5.0.0 impl#[`ColoredFormatter<F>`]to_colored_json().( |
| 217 | &jsonrust-analyzer cargo serde_json 1.0.85 macros/json!!({ |
| 218 | "string": "string", |
| 219 | "integer": 4398798674962568u64, |
| 220 | "float": 3.1415926, |
| 221 | "array": [ |
| 222 | "ele1", |
| 223 | "ele2" |
| 224 | ] |
| 225 | }), |
| 226 | ColorModerust-analyzer cargo colored_json 5.0.0 ColorMode#::Offrust-analyzer cargo colored_json 5.0.0 ColorMode#Off#, |
| 227 | )?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). |
| 228 | ); |
| 229 | |
| 230 | printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!( |
| 231 | "{}", |
| 232 | f.to_colored_json_autorust-analyzer cargo colored_json 5.0.0 impl#[`ColoredFormatter<F>`]to_colored_json_auto().(&jsonrust-analyzer cargo serde_json 1.0.85 macros/json!!({ |
| 233 | "name":"John", "age":31, "city":"New York" |
| 234 | }))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). |
| 235 | ); |
| 236 | |
| 237 | return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()); |
| 238 | } |
| 239 | |
| 240 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 241 | fn test_styler_compactrust-analyzer cargo colored_json 5.0.0 test_styler_compact().() -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error#>> { |
| 242 | let f = ColoredFormatterrust-analyzer cargo colored_json 5.0.0 ColoredFormatter#::with_stylerrust-analyzer cargo colored_json 5.0.0 impl#[`ColoredFormatter<F>`]with_styler().( |
| 243 | CompactFormatterrust-analyzer cargo serde_json 1.0.85 ser/CompactFormatter# {}, |
| 244 | Stylerrust-analyzer cargo colored_json 5.0.0 Styler# { |
| 245 | keyrust-analyzer cargo colored_json 5.0.0 Styler#key.: Colorrust-analyzer cargo yansi 1.0.1 color/Color#::Greenrust-analyzer cargo yansi 1.0.1 color/Color#Green#.foregroundrust-analyzer cargo yansi 1.0.1 color/impl#[Color]foreground().(), |
| 246 | string_valuerust-analyzer cargo colored_json 5.0.0 Styler#string_value.: Colorrust-analyzer cargo yansi 1.0.1 color/Color#::Bluerust-analyzer cargo yansi 1.0.1 color/Color#Blue#.boldrust-analyzer cargo yansi 1.0.1 color/impl#[Color]bold().(), |
| 247 | integer_valuerust-analyzer cargo colored_json 5.0.0 Styler#integer_value.: Colorrust-analyzer cargo yansi 1.0.1 color/Color#::Bluerust-analyzer cargo yansi 1.0.1 color/Color#Blue#.boldrust-analyzer cargo yansi 1.0.1 color/impl#[Color]bold().(), |
| 248 | ..Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#::defaultrust-analyzer cargo colored_json 5.0.0 impl#[Styler][Default]default().() |
| 249 | }, |
| 250 | ); |
| 251 | |
| 252 | printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!( |
| 253 | "\n{}", |
| 254 | f.clonerust-analyzer cargo colored_json 5.0.0 impl#[`ColoredFormatter<F>`][Clone]clone().().to_colored_json_autorust-analyzer cargo colored_json 5.0.0 impl#[`ColoredFormatter<F>`]to_colored_json_auto().(&jsonrust-analyzer cargo serde_json 1.0.85 macros/json!!({ |
| 255 | "name": "John Doe", |
| 256 | "age": 43, |
| 257 | "phones": [ |
| 258 | "+44 1234567", |
| 259 | "+44 2345678" |
| 260 | ] |
| 261 | }))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). |
| 262 | ); |
| 263 | |
| 264 | printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!( |
| 265 | "{}", |
| 266 | f.to_colored_json_autorust-analyzer cargo colored_json 5.0.0 impl#[`ColoredFormatter<F>`]to_colored_json_auto().(&jsonrust-analyzer cargo serde_json 1.0.85 macros/json!!({ |
| 267 | "name":"John", "age":31, "city":"New York" |
| 268 | }))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). |
| 269 | ); |
| 270 | |
| 271 | return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()); |
| 272 | } |
| 273 | |
| 274 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 275 | fn test_serializesrust-analyzer cargo colored_json 5.0.0 test_serializes().() -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error#>> { |
| 276 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(serderust-analyzer cargo serde 1.0.144 crate/::Serializerust-analyzer cargo serde_derive 1.0.144 Serialize:)] |
| 277 | struct Datarust-analyzer cargo colored_json 5.0.0 Data#<'a> { |
| 278 | namerust-analyzer cargo colored_json 5.0.0 Data#name.: &'a str, |
| 279 | agerust-analyzer cargo colored_json 5.0.0 Data#age.: usize, |
| 280 | phonesrust-analyzer cargo colored_json 5.0.0 Data#phones.: &'a [&'a str], |
| 281 | } |
| 282 | |
| 283 | let data = Datarust-analyzer cargo colored_json 5.0.0 Data# { |
| 284 | namerust-analyzer cargo colored_json 5.0.0 Data#name.: "John Doe", |
| 285 | agerust-analyzer cargo colored_json 5.0.0 Data#age.: 43, |
| 286 | phonesrust-analyzer cargo colored_json 5.0.0 Data#phones.: &["+44 1234567", "+44 2345678"], |
| 287 | }; |
| 288 | |
| 289 | let s = to_colored_json_autorust-analyzer cargo colored_json 5.0.0 to_colored_json_auto().(&data)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 290 | printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("\n{}", s); |
| 291 | |
| 292 | return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()); |
| 293 | } |