Bump toml from 0.5.11 to 0.6.0 (#736)

* Bump toml from 0.5.11 to 0.6.0

Bumps [toml](https://github.com/toml-rs/toml) from 0.5.11 to 0.6.0.
- [Release notes](https://github.com/toml-rs/toml/releases)
- [Commits](https://github.com/toml-rs/toml/compare/toml-v0.5.11...toml-v0.6.0)

---
updated-dependencies:
- dependency-name: toml
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Fix use of `toml` v0.6
* Optimize `CratesTomlParseError`: Box variant `TomlParse`
   Since now `toml:🇩🇪:Error` is a wrapper of `toml_edit::TomlError`,
   which is at least 3 * `size_of::<Vec<_>>()`.

Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
dependabot[bot] 2023-01-24 02:51:29 +00:00 committed by GitHub
parent 9a2b4c9ab1
commit 425c6c2509
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 69 additions and 7 deletions

View file

@ -13,6 +13,7 @@ use std::{
io::{self, Seek},
iter::IntoIterator,
path::{Path, PathBuf},
str::{self, Utf8Error},
};
use beef::Cow;
@ -54,7 +55,7 @@ impl CratesToml<'_> {
if vec.is_empty() {
Ok(CratesToml::default())
} else {
toml::from_slice(&vec).map_err(CratesTomlParseError::from)
toml::from_str(str::from_utf8(&vec)?).map_err(CratesTomlParseError::from)
}
}
@ -89,7 +90,7 @@ impl CratesToml<'_> {
this: &CratesToml<'_>,
writer: &mut dyn io::Write,
) -> Result<(), CratesTomlParseError> {
let data = toml::to_vec(&this)?;
let data = toml::to_string(&this)?.into_bytes();
writer.write_all(&data)?;
Ok(())
}
@ -184,8 +185,11 @@ pub enum CratesTomlParseError {
#[error(transparent)]
Io(#[from] io::Error),
#[error("Failed to parse toml: File is not in valid utf-8 encodings: {0}")]
TomlParseNonUtf8(#[from] Utf8Error),
#[error(transparent)]
TomlParse(#[from] toml::de::Error),
TomlParse(Box<toml::de::Error>),
#[error(transparent)]
TomlWrite(Box<toml::ser::Error>),
@ -206,6 +210,12 @@ impl From<toml::ser::Error> for CratesTomlParseError {
}
}
impl From<toml::de::Error> for CratesTomlParseError {
fn from(e: toml::de::Error) -> Self {
CratesTomlParseError::TomlParse(Box::new(e))
}
}
#[cfg(test)]
mod tests {
use super::*;