Skip to content

Add file IO with Vec<T> example#573

Merged
juntyr merged 5 commits into
ron-rs:masterfrom
LanHikari22:add_vec_file_read_write_example
Jul 8, 2025
Merged

Add file IO with Vec<T> example#573
juntyr merged 5 commits into
ron-rs:masterfrom
LanHikari22:add_vec_file_read_write_example

Conversation

@LanHikari22

@LanHikari22 LanHikari22 commented Jun 22, 2025

Copy link
Copy Markdown
Contributor

Issue associated with this PR is #572.

  • I've included my change in CHANGELOG.md

@juntyr

juntyr commented Jun 22, 2025

Copy link
Copy Markdown
Member

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
Copy Markdown
Contributor 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

Comment thread examples/file_read_write_vec.rs Outdated
Comment thread examples/file_read_write_vec.rs Outdated
- 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.
@juntyr

juntyr commented Jun 28, 2025

Copy link
Copy Markdown
Member

@LanHikari22 Once you address the CI failures, I'm happy to merge this PR

- Fixed crate use formatting issues
- Fixed ? Issues by turning File Errors into Error::Io explicitly. This
  only fails when passing --no-default-features flag.
@LanHikari22

Copy link
Copy Markdown
Contributor Author

@juntyr Hi Juniper,

Apologies for the delay. All CI failures seem resolved.

Thanks,
Lan

@juntyr juntyr merged commit 29e244a into ron-rs:master Jul 8, 2025
12 checks passed
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