Skip to content
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

Merged
merged 2 commits into from
Jan 24, 2018
Merged

Pretty sequence indexing #86

merged 2 commits into from
Jan 24, 2018

Conversation

kvark
Copy link
Collaborator

@kvark kvark commented Jan 24, 2018

This is super useful when inspecting serialized vectors for an ability to quicky jump to an element by index. Looks like this:

    array: [
        (),// [0]
        (),// [1]
        (),// [2]
    ],

Ideally, I'd like to see it like this:

    array: [
        /*0*/ (),
        /*1*/ (),
        /*2*/ (),
    ],

But this is blocked on supporting those types of comments.

@kvark kvark requested a review from torkleyy January 24, 2018 03:50
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,
Copy link

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?

Copy link
Collaborator Author

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?

Copy link
Contributor

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.

Copy link
Contributor

@torkleyy torkleyy left a 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.
Copy link
Contributor

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,
Copy link
Contributor

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.

@kvark
Copy link
Collaborator Author

kvark commented Jan 24, 2018

@torkleyy thanks for feedback! PTAL

@torkleyy
Copy link
Contributor

Thank you!

bors r+

bors bot added a commit that referenced this pull request Jan 24, 2018
87: [v0.1] Implement sequence indexing r=torkleyy a=kvark

Brother of #86 for our released branch.
bors bot added a commit that referenced this pull request Jan 24, 2018
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.
@bors
Copy link
Contributor

bors bot commented Jan 24, 2018

Build succeeded

@bors bors bot merged commit cde0577 into ron-rs:master Jan 24, 2018
@kvark kvark deleted the sequence-index branch January 24, 2018 18:46
@kvark kvark mentioned this pull request Jan 24, 2018
bors bot added a commit that referenced this pull request Jan 24, 2018
88: Deep array indexing r=torkleyy a=kvark

Follow-up to #86 that supports nested arrays (ouch).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants