8000 Add file IO with Vec<T> example by LanHikari22 · Pull Request #573 · ron-rs/ron · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add file IO with Vec<T> example #573

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

LanHikari22
Copy link
@LanHikari22 LanHikari22 commented Jun 22, 2025

Issue associated with this PR is #572.

  • I've included my change in CHANGELOG.md

@juntyr
Copy link
Member
juntyr commented Jun 22, 2025

Thank you for this PR!

I think that using ron for several rows is an interesting use case and does deserve its own example.

However, I think it might be neater to actually keep one entry per row by serialising entries without line separators and with escaped strings (both can be configured in the pretty config). Then we wouldn't need a magic entry separator, though of course one would also be restricted to not use new lines when writing entries by hand.

In any case, it seems like AI was involved in creating this PR. Please review all code manually again to make sure it has natural flow and that e.g. no test files from other examples are overriden.

Thank you for your contribution to Ron!

- Ensured example works under `0.10.1` and not just `0.8.x`.
- Ensured that new lines added per entry handled windows/non-windows
- Ensured that the example.ron file is deleted after testing
@LanHikari22
Copy link
Author

Thank you for your feedback!

I have updated the example to remove the magic seperator. Thank you for pointing me towards configuring PrettyConfig. Now with all compact setings on, I was able to ensure one row per entry.

In the development journal, AI had suggested RON, but I did not use it to create the example code or modify any files in the repository. I have reviewed the code and it looks fairly minimal. Please feel free to give any further feedback.

Thank you!
Lan

]
}

// A basic text file format with individual records separated by a magic separator
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// A basic text file format with individual records separated by a magic separator
// A basic text file format with one individual record per line

Copy link
Author
@LanHikari22 LanHikari22 Jun 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. Should be good now. Thanks for catching the outdated comment.

pub fn main() {
let users = create_records();

let path = PathBuf::from_str("example.ron").unwrap();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we use a different file name here, e.g. vec-example.ron?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes! Changed it to vec-example.ron.

- Clarify comments and remove outdated comments about magic seperator
- Rename example file generated from `example.ron` to `vec-example.ron`
- Simplify `read_ron_vec_from_str`. It no longer needs to trim the
  string or filter out empties.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0