-
Notifications
You must be signed in to change notification settings - Fork 136
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
base: master
Are you sure you want to change the base?
Add file IO with Vec<T> example #573
Conversation
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
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! |
examples/file_read_write_vec.rs
Outdated
] | ||
} | ||
|
||
// A basic text file format with individual records separated by a magic separator |
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.
// A basic text file format with individual records separated by a magic separator | |
// A basic text file format with one individual record per 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.
Fixed. Should be good now. Thanks for catching the outdated comment.
examples/file_read_write_vec.rs
Outdated
pub fn main() { | ||
let users = create_records(); | ||
|
||
let path = PathBuf::from_str("example.ron").unwrap(); |
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.
Could we use a different file name here, e.g. vec-example.ron
?
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.
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.
Issue associated with this PR is #572.
CHANGELOG.md