diff --git a/crates/toml_edit/src/encode.rs b/crates/toml_edit/src/encode.rs index 1da651aa..fd5eeec0 100644 --- a/crates/toml_edit/src/encode.rs +++ b/crates/toml_edit/src/encode.rs @@ -419,13 +419,17 @@ fn infer_style( (Some(style), Some(literal)) => (style, literal), (None, Some(literal)) => (infer_all_style(value).0, literal), (Some(style), None) => { - let literal = !value.contains('\'') && (value.contains('"') | value.contains('\\')); + let literal = infer_literal(value); (style, literal) } (None, None) => infer_all_style(value), } } +fn infer_literal(value: &str) -> bool { + !value.contains('\'') && (value.contains('"') | value.contains('\\')) +} + fn infer_all_style(value: &str) -> (StringStyle, bool) { // We need to determine: // - if we are a "multi-line" pretty (if there are \n)