rust-lang/rust — pull request #16601 by cybergeek94 (2014-08-19 11:07:24+00:00)
Title: Parameterize indent step in serlialize::json::PrettyEncoder

Previously, `PrettyEncoder` indented a constant 2 spaces per level (a "magic number" as can be seen in the diff), which may be fine for most uses but in my use case I would like to allow the user to specify the indent step for the outputted JSON in my program.

This is small change that does not break any existing code whatsoever, and does not change the behavior of existing uses. `PrettyEncoder::new()` still uses the default of 2.

I couldn't think of any simple tests for this change. The obvious one would be to check the outputted JSON for the correct number of spaces per indent level, but I think that would be more complex than the actual change itself and test little besides correctness and consistency, which can be verified visually. There's already a test for correct parsing of pretty-printed JSON that still passes with this change.

This is passing as of rust-lang/rust@dee8313.