mirror of
https://github.com/nushell/nushell.git
synced 2025-06-30 14:40:06 +02:00
add "to nuon" enumeration of possible styles (#12591)
# Description
in order to change the style of the _serialized_ NUON data,
`nuon::to_nuon` takes three mutually exclusive arguments, `raw: bool`,
`tabs: Option<usize>` and `indent: Option<usize>` 🤔
this begs to use an enumeration with all possible alternatives, right?
this PR changes the signature of `nuon::to_nuon` to use `nuon::ToStyle`
which has three variants
- `Raw`: no newlines
- `Tabs(n: usize)`: newlines and `n` tabulations as indent
- `Spaces(n: usize)`: newlines and `n` spaces as indent
# User-Facing Changes
the signature of `nuon::to_nuon` changes from
```rust
to_nuon(
input: &Value,
raw: bool,
tabs: Option<usize>,
indent: Option<usize>,
span: Option<Span>,
) -> Result<String, ShellError>
```
to
```rust
to_nuon(
input: &Value,
style: ToStyle,
span: Option<Span>
) -> Result<String, ShellError>
```
# Tests + Formatting
# After Submitting
This commit is contained in:
@ -330,7 +330,7 @@ fn into_sqlite_big_insert() {
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let nuon = nuon::to_nuon(&value, true, None, None, Some(Span::unknown())).unwrap()
|
||||
let nuon = nuon::to_nuon(&value, nuon::ToStyle::Raw, Some(Span::unknown())).unwrap()
|
||||
+ &line_ending();
|
||||
|
||||
nuon_file.write_all(nuon.as_bytes()).unwrap();
|
||||
|
Reference in New Issue
Block a user