diff options
| author | Michael Killough <michaeljkillough@gmail.com> | 2017-05-16 15:47:09 +0700 |
|---|---|---|
| committer | Michael Killough <michaeljkillough@gmail.com> | 2017-05-16 15:47:09 +0700 |
| commit | c0bdbfa5315217741213d04329b02a4fb5e061e7 (patch) | |
| tree | d0c03d2899942bf1fcd60c2807213b4b9144c2e8 /src/string.rs | |
| parent | 09e5051deed87b4c2eee5be6f5868e14380fe996 (diff) | |
Switch to accessing config items via method.
Preparation for #865, which proposes adding a flag which outputs which config options are used during formatting. This PR should not make any difference to functionality. A lot of this was search-and-replace. Some areas worthy of review/discussion: - The method for each config item returns a clone of the underlying value. We can't simply return an immutable reference, as lots of places in the code expect to be able to pass the returned value as `bool` (not `&bool). It would be nice if the `bool` items could return a copy, but the more complex types a borrowed reference... but unfortunately, I couldn't get the macro to do this. - A few places (mostly tests and `src/bin/rustfmt.rs`) were overriding config items by modifying the fields of the `Config` struct directly. They now use the existing `override_value()` method, which has been modified to return a `Result` for use by `src/bin/rustfmt.rs`. This benefits of this are that the complex `file_lines` and `write_mode` strings are now parsed in one place (`Config.override_value`) instead of multiple. The disadvantages are that it moves the compile-time checks for config names to become run-time checks.
Diffstat (limited to 'src/string.rs')
| -rw-r--r-- | src/string.rs | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/string.rs b/src/string.rs index 37a569ce67d..365d205aef1 100644 --- a/src/string.rs +++ b/src/string.rs @@ -119,7 +119,7 @@ pub fn rewrite_string<'a>(orig: &str, fmt: &StringFormat<'a>) -> Option<String> } result.push_str(fmt.closer); - wrap_str(result, fmt.config.max_width, fmt.shape) + wrap_str(result, fmt.config.max_width(), fmt.shape) } #[cfg(test)] |
