mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-04-24 22:30:03 +00:00
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:
parent
9a2b4c9ab1
commit
425c6c2509
3 changed files with 69 additions and 7 deletions
|
@ -21,7 +21,7 @@ serde = { version = "1.0.152", features = ["derive"] }
|
|||
serde-tuple-vec-map = "1.0.1"
|
||||
serde_json = "1.0.91"
|
||||
thiserror = "1.0.38"
|
||||
toml = "0.5.11"
|
||||
toml = "0.6.0"
|
||||
url = { version = "2.3.1", features = ["serde"] }
|
||||
|
||||
[dev-dependencies]
|
||||
|
|
|
@ -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::*;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue