-
Notifications
You must be signed in to change notification settings - Fork 124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pretty sequence indexing #86
Conversation
src/ser/mod.rs
Outdated
@@ -97,6 +97,7 @@ impl Default for PrettyConfig { | |||
new_line: "\r\n".to_string(), | |||
indentor: " ".to_string(), | |||
separate_tuple_members: false, | |||
enumerate_arrays: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmmm, are you sure that this option should be enabled by default?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really. Would you not want to see the indices?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with @ozkriff, I think it's too noisy for it to be the default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like it! Maybe a small test could be added (which checks that it enumerates the elements correctly and that it can be deserialized again).
src/ser/mod.rs
Outdated
if config.enumerate_arrays { | ||
//TODO: when /**/ comments are supported, prepend the index | ||
// to an element instead of appending it. | ||
// Note: this doesn't if `new_line` is not an actual new line. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest we assert that PrettyConfig::new_line
contains a b'\n'
on creation.
src/ser/mod.rs
Outdated
@@ -97,6 +97,7 @@ impl Default for PrettyConfig { | |||
new_line: "\r\n".to_string(), | |||
indentor: " ".to_string(), | |||
separate_tuple_members: false, | |||
enumerate_arrays: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with @ozkriff, I think it's too noisy for it to be the default.
@torkleyy thanks for feedback! PTAL |
Thank you! bors r+ |
86: Pretty sequence indexing r=torkleyy a=kvark This is super useful when inspecting serialized vectors for an ability to quicky jump to an element by index. Looks like this: ```rust array: [ (),// [0] (),// [1] (),// [2] ], ``` Ideally, I'd like to see it like this: ```rust array: [ /*0*/ (), /*1*/ (), /*2*/ (), ], ``` But this is blocked on supporting those types of comments.
Build succeeded |
This is super useful when inspecting serialized vectors for an ability to quicky jump to an element by index. Looks like this:
Ideally, I'd like to see it like this:
But this is blocked on supporting those types of comments.