Skip to content

Commit

Permalink
switch from toml::from_slice to toml::from_str
Browse files Browse the repository at this point in the history
  • Loading branch information
pascalkuthe committed Jan 23, 2023
1 parent 17acadb commit 1ee1d3b
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions helix-loader/src/config.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
use std::str::from_utf8;

/// Default built-in languages.toml.
pub fn default_lang_config() -> toml::Value {
toml::from_slice(include_bytes!("../../languages.toml"))
let default_config = include_bytes!("../../languages.toml");
toml::from_str(from_utf8(default_config).unwrap())
.expect("Could not parse built-in languages.toml to valid toml")
}

Expand All @@ -11,8 +14,8 @@ pub fn user_lang_config() -> Result<toml::Value, toml::de::Error> {
.chain([crate::config_dir()].into_iter())
.map(|path| path.join("languages.toml"))
.filter_map(|file| {
std::fs::read(&file)
.map(|config| toml::from_slice(&config))
std::fs::read_to_string(&file)
.map(|config| toml::from_str(&config))
.ok()
})
.collect::<Result<Vec<_>, _>>()?
Expand Down

0 comments on commit 1ee1d3b

Please sign in to comment.