Every now and then, people post here looking for suggestions for project to learn Rust. I have one: A crate that can read TOML files, edit them, and save them without loosing comments and whitespace.

In killercup/cargo-edit#15, we saw that the toml crate by @alexcrichton can read TOMl just fine, but when editing and saving a file, it looses information that is important to humans (e.g. the order of tables, comments and whitespace). @flying_sheep suggested that writing a new crate that supports this might be a nice project for a Rust beginner (though not necessarily a person who is also learning to program).

If you want to write such a crate, here are some useful links:

This PR on the original toml crate has a “very rough implementation of round-tripping TOML parser”

crate has a “very rough implementation of round-tripping TOML parser” You might want to look at parser combinators like nom or a parser generator like lalrpop

A bunch of tips for setting up a Rust library project

The use case I have for this is editing Cargo.toml files in cargo-edit but I’m sure such a crate will be nice to have in other project as well.

Please comment here or on Github if you want to do this, and/or if you need any help