Skip to content

Commit

Permalink
fix(deps): update rust crate toml_edit to 0.22.7 (#1783)
Browse files Browse the repository at this point in the history
* fix(deps): update rust crate toml_edit to 0.22.7

* fix deprecation warnings

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Jeff Dickey <[email protected]>
  • Loading branch information
renovate[bot] and jdx authored Mar 16, 2024
1 parent 5edf8dd commit 4187cd7
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 26 deletions.
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ tera = { version = "1.19.1", default-features = false }
terminal_size = "0.3.0"
thiserror = "1.0.58"
toml = { version = "0.8.10", features = ["parse"] }
toml_edit = { version = "0.22.6", features = ["parse"] }
toml_edit = { version = "0.22.7", features = ["parse"] }
url = "2.5.0"
usage-lib = { version="0.1.9", features = ["clap"] }
versions = { version = "6.1.0" , features=["serde"]}
Expand Down
4 changes: 2 additions & 2 deletions src/cli/settings/set.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use eyre::Result;
use toml_edit::Document;
use toml_edit::DocumentMut;

use crate::config::settings::SettingsFile;

Expand Down Expand Up @@ -61,7 +61,7 @@ impl SettingsSet {
let path = &*env::MISE_GLOBAL_CONFIG_FILE;
file::create_dir_all(path.parent().unwrap())?;
let raw = file::read_to_string(path).unwrap_or_default();
let mut config: Document = raw.parse()?;
let mut config: DocumentMut = raw.parse()?;
if !config.contains_key("settings") {
config["settings"] = toml_edit::Item::Table(toml_edit::Table::new());
}
Expand Down
4 changes: 2 additions & 2 deletions src/cli/settings/unset.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use eyre::Result;
use toml_edit::Document;
use toml_edit::DocumentMut;

use crate::{env, file};

Expand All @@ -17,7 +17,7 @@ impl SettingsUnset {
pub fn run(self) -> Result<()> {
let path = env::MISE_CONFIG_DIR.join("config.toml");
let raw = file::read_to_string(&path)?;
let mut settings: Document = raw.parse()?;
let mut settings: DocumentMut = raw.parse()?;
settings.remove(&self.setting);
file::write(&path, settings.to_string())
}
Expand Down
30 changes: 15 additions & 15 deletions src/config/config_file/mise_toml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use serde::de::Visitor;
use serde::{de, Deserializer};
use serde_derive::Deserialize;
use tera::Context as TeraContext;
use toml_edit::{table, value, Array, Document, Item, Value};
use toml_edit::{table, value, Array, DocumentMut, Item, Value};
use versions::Versioning;

use crate::cli::args::{ForgeArg, ToolVersionType};
Expand Down Expand Up @@ -43,7 +43,7 @@ pub struct MiseToml {
#[serde(default, deserialize_with = "deserialize_alias")]
alias: AliasMap,
#[serde(skip)]
doc: OnceCell<Document>,
doc: OnceCell<DocumentMut>,
#[serde(default)]
tools: IndexMap<ForgeArg, MiseTomlToolList>,
#[serde(default)]
Expand Down Expand Up @@ -97,14 +97,14 @@ impl MiseToml {
Ok(rf)
}

fn doc(&self) -> eyre::Result<&Document> {
fn doc(&self) -> eyre::Result<&DocumentMut> {
self.doc.get_or_try_init(|| {
let body = file::read_to_string(&self.path).unwrap_or_default();
Ok(body.parse()?)
})
}

fn doc_mut(&mut self) -> eyre::Result<&mut Document> {
fn doc_mut(&mut self) -> eyre::Result<&mut DocumentMut> {
self.doc()?;
Ok(self.doc.get_mut().unwrap())
}
Expand Down Expand Up @@ -640,6 +640,17 @@ impl<'de> de::Deserialize<'de> for MiseTomlToolList {
}]))
}

fn visit_seq<S>(self, mut seq: S) -> std::result::Result<Self::Value, S::Error>
where
S: de::SeqAccess<'de>,
{
let mut tools = vec![];
while let Some(tool) = seq.next_element::<MiseTomlTool>()? {
tools.push(tool);
}
Ok(MiseTomlToolList(tools))
}

fn visit_map<M>(self, map: M) -> std::result::Result<Self::Value, M::Error>
where
M: de::MapAccess<'de>,
Expand All @@ -656,17 +667,6 @@ impl<'de> de::Deserialize<'de> for MiseTomlToolList {
.map_err(de::Error::custom)?;
Ok(MiseTomlToolList(vec![MiseTomlTool { tt, options }]))
}

fn visit_seq<S>(self, mut seq: S) -> std::result::Result<Self::Value, S::Error>
where
S: de::SeqAccess<'de>,
{
let mut tools = vec![];
while let Some(tool) = seq.next_element::<MiseTomlTool>()? {
tools.push(tool);
}
Ok(MiseTomlToolList(tools))
}
}

deserializer.deserialize_any(MiseTomlToolListVisitor)
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/mise_plugin_toml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::path::Path;

use color_eyre::eyre::eyre;
use color_eyre::{Result, Section};
use toml_edit::{Document, Item, Value};
use toml_edit::{DocumentMut, Item, Value};

use crate::{file, parse_error};

Expand Down Expand Up @@ -39,7 +39,7 @@ impl MisePluginToml {
}

fn parse(&mut self, s: &str) -> Result<()> {
let doc: Document = s.parse().suggestion("ensure file is valid TOML")?;
let doc: DocumentMut = s.parse().suggestion("ensure file is valid TOML")?;
for (k, v) in doc.iter() {
match k {
"exec-env" => self.exec_env = self.parse_script_config(k, v)?,
Expand Down

0 comments on commit 4187cd7

Please sign in to comment.