Published on

new TOML crate

Authors
  • avatar
    Name
    ttyS3
    Twitter

今天检查邮箱发现 https://github.com/toml-rs/toml-rs/issues/392 这个 issue 有更新.

由于 toml 这个 crate 完成的时候, TOML 标准本身还没有达到 1.0.0 稳定版, 因此这个 crate 实际上只实现了 TOML 标准 0.5 版本的功能.

但是现在 TOML 标准已经到了 1.0.0 版本, 而 toml 这个 crate 的维护者却一直没有更新. 由于有了这个 issue, 讨论何时更新到1.0版本.

这是一个 2020 年的 issue. 一直没啥动静, 值得高兴的时候, 昨天终于有变动了:

https://github.com/toml-rs/toml-rs/issues/392#issuecomment-1256456721

Maintenance of this crate has moved to the toml-rs/toml repo. As a heads up, we plan to move toml to be on top of toml_edit, see toml-rs/toml#340.

Closing this out. If this is still a problem, feel free to recreate this issue in the new repo.

现在, 如果你打开 https://github.com/toml-rs/toml-rs, 会发现 readme 已经变成了:

Development of the toml crate has moved to https://github.com/toml-rs/toml/tree/master/crates/toml.

This repo is now archived.

其实还有一个 toml-rs/toml-rs 的作者为这个项目寻找新的维护者的issue, https://github.com/toml-rs/toml-rs/issues/460

I personally no longer have the time or energy to maintain this crate. I believe this is still pretty widely used as the default TOML implementation for Rust, however, so it'd be good to keep this maintained. I'm opening this to see if there is another who is willing to take over ownership and maintenance of this crate. In the meantime I will not be maintaining this crate other than if a security issue arises.

今年6月左右 https://github.com/toml-rs/toml-rs/issues/460#issuecomment-1163202480:

epage 写道:

@alexcrichton what if we moved toml_edit::easy into toml?

A task I've been meaning to get to is to restructure toml_edit so a subset can more easily show up in public APIs, like cargo_metadata including toml. One possible route for that is to split toml_edit::easy out into its own crate and not expose any toml_edit types.

The downside being that toml_edit::easy has a ceiling on how fast it can get due to the format-preserving core its built on, even if the performance right now is roughly on par with toml.

toml_edit 又是啥呢? 它现在已经被 cargo 使用了: https://github.com/rust-lang/cargo/pull/10086

根据这个 PR 的描述, 它是 A TOML 1.0 compliant parser

有个小问题就是, alexcrichton 将 toml-rs 的仓库转移到了 epage 的 toml-rs github 组织下面后(仓库从 alexcrichton/toml-rs 变成了 toml-rs/toml-rs ),

epage 关闭了旧仓库 (toml-rs/toml-rs) 的所有 issue, 并且这些 issue 似乎没有被转移到新的 repo (toml-rs/toml) 下面. 有一些用户对此感到不满, 主要在 https://github.com/toml-rs/toml/issues/340 里面, 被隐藏的一评论.

不管怎么说, toml 这个 crate 重新重新有人维护了. 要感谢 alexcrichton, 它不但允许 epage 接管后, 继续使用 toml 这个 crate 名字, 而且将原来的 toml-rs 仓库也转移给了他.

所以, 新的 toml 库能继续使用 toml crate 这个名字, 并且旧使用也可以继续升级.

根据 https://crates.io/crates/toml 这个 crate 每天的下载量大概在 10万左右.

toml_edit 使用的 parser 是 https://docs.rs/combine, 其实它早期使用的是 nom, 至于为什么迁移到了 combine, 见这个issue : https://github.com/toml-rs/toml/issues/16

nom is great for parsing binary formats, but no-so-great for parsing languages and reporting human readable errors. I'm considering combine, pest (procedural branch), peg, larlpop at the moment.

目前 toml_edit 有个问题还没解决就是编译很慢: toml_edit is pretty slow to compile https://github.com/toml-rs/toml/issues/327

对比 https://github.com/rosetta-rs/parse-rosetta-rs

Refs

combine vs nom 对比: https://github.com/Marwes/combine/issues/73

parser benchmark: https://github.com/rosetta-rs/parse-rosetta-rs

Migrate toml to be on toml_edit https://github.com/toml-rs/toml/issues/340