return Some(string_lit);
}
- let fmt = StringFormat {
- opener: "\"",
- closer: "\"",
- line_start: " ",
- line_end: "\\",
- shape: shape,
- trim_end: false,
- config: context.config,
- };
-
// Remove the quote characters.
let str_lit = &string_lit[1..string_lit.len() - 1];
- rewrite_string(str_lit, &fmt)
+ rewrite_string(str_lit, &StringFormat::new(shape, context.config))
}
fn string_requires_rewrite(
pub config: &'a Config,
}
+impl<'a> StringFormat<'a> {
+ pub fn new(shape: Shape, config: &'a Config) -> StringFormat<'a> {
+ StringFormat {
+ opener: "\"",
+ closer: "\"",
+ line_start: " ",
+ line_end: "\\",
+ shape: shape,
+ trim_end: false,
+ config: config,
+ }
+ }
+}
+
// FIXME: simplify this!
pub fn rewrite_string<'a>(orig: &str, fmt: &StringFormat<'a>) -> Option<String> {
// Strip line breaks.
#[test]
fn issue343() {
let config = Default::default();
- let fmt = StringFormat {
- opener: "\"",
- closer: "\"",
- line_start: " ",
- line_end: "\\",
- shape: Shape::legacy(2, Indent::empty()),
- trim_end: false,
- config: &config,
- };
-
+ let fmt = StringFormat::new(Shape::legacy(2, Indent::empty()), &config);
rewrite_string("eq_", &fmt);
}
}