aboutsummaryrefslogtreecommitdiff
path: root/helix-view/src
diff options
context:
space:
mode:
authorPascal Kuthe2023-01-24 16:07:01 +0000
committerGitHub2023-01-24 16:07:01 +0000
commite9dc9f493554bd54ea3710e66a2fb0fd2e70b462 (patch)
tree0b862501d0f5613a3c8dfe47789219ad985e0440 /helix-view/src
parent64ec0256d3e41d6b6e5a24f749489880a147ab8a (diff)
Switch from toml::from_slice to toml::from_str (#5659)
Diffstat (limited to 'helix-view/src')
-rw-r--r--helix-view/src/theme.rs12
1 files changed, 7 insertions, 5 deletions
diff --git a/helix-view/src/theme.rs b/helix-view/src/theme.rs
index cb0d3ac4..9eae88a8 100644
--- a/helix-view/src/theme.rs
+++ b/helix-view/src/theme.rs
@@ -1,6 +1,7 @@
use std::{
collections::HashMap,
path::{Path, PathBuf},
+ str,
};
use anyhow::{anyhow, Context, Result};
@@ -15,12 +16,13 @@ use crate::graphics::UnderlineStyle;
pub use crate::graphics::{Color, Modifier, Style};
pub static DEFAULT_THEME_DATA: Lazy<Value> = Lazy::new(|| {
- toml::from_slice(include_bytes!("../../theme.toml")).expect("Failed to parse default theme")
+ let bytes = include_bytes!("../../theme.toml");
+ toml::from_str(str::from_utf8(bytes).unwrap()).expect("Failed to parse base default theme")
});
pub static BASE16_DEFAULT_THEME_DATA: Lazy<Value> = Lazy::new(|| {
- toml::from_slice(include_bytes!("../../base16_theme.toml"))
- .expect("Failed to parse base 16 default theme")
+ let bytes = include_bytes!("../../base16_theme.toml");
+ toml::from_str(str::from_utf8(bytes).unwrap()).expect("Failed to parse base 16 default theme")
});
pub static DEFAULT_THEME: Lazy<Theme> = Lazy::new(|| Theme {
@@ -148,8 +150,8 @@ impl Loader {
// Loads the theme data as `toml::Value` first from the user_dir then in default_dir
fn load_toml(&self, path: PathBuf) -> Result<Value> {
- let data = std::fs::read(&path)?;
- let value = toml::from_slice(data.as_slice())?;
+ let data = std::fs::read_to_string(&path)?;
+ let value = toml::from_str(&data)?;
Ok(value)
}