Skip to content

Commit

Permalink
chore: Apply review feedback
Browse files Browse the repository at this point in the history
- fix: `HashMap` =>  `Map` to avoid compilation error
  Original author: MGlolenstine
- fix: `Integer` => `I64`
  `ValueKind` enum has changed since the original PR went stale.
- chore: Version bump `serde_dhall` to `0.12`

Signed-off-by: Brennan Kinney <[email protected]>
  • Loading branch information
polarathene committed Oct 5, 2023
1 parent fe1b043 commit 35a8b56
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ yaml-rust = { version = "0.4", optional = true }
rust-ini = { version = "0.19", optional = true }
ron = { version = "0.8", optional = true }
json5_rs = { version = "0.4", optional = true, package = "json5" }
serde_dhall = { version = "0.10", optional = true }
serde_dhall = { version = "0.12", optional = true }
indexmap = { version = "2.0.0", features = ["serde"], optional = true }
convert_case = { version = "0.6", optional = true }
pathdiff = "0.2"
Expand Down
10 changes: 5 additions & 5 deletions src/file/format/dhall.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::collections::HashMap;
use crate::map::Map;
use std::error::Error;

use crate::{
Expand All @@ -10,13 +10,13 @@ use crate::{
pub fn parse(
uri: Option<&String>,
text: &str,
) -> Result<HashMap<String, Value>, Box<dyn Error + Send + Sync>> {
) -> Result<Map<String, Value>, Box<dyn Error + Send + Sync>> {
let value = from_dhall_value(uri, serde_dhall::from_str(text).parse()?);
match value.kind {
ValueKind::Table(map) => Ok(map),
ValueKind::Nil => Err(Unexpected::Unit),
ValueKind::Boolean(value) => Err(Unexpected::Bool(value)),
ValueKind::Integer(value) => Err(Unexpected::Integer(value)),
ValueKind::I64(value) => Err(Unexpected::I64(value)),
ValueKind::Float(value) => Err(Unexpected::Float(value)),
ValueKind::String(value) => Err(Unexpected::Str(value)),
ValueKind::Array(value) => Err(Unexpected::Seq),
Expand All @@ -29,8 +29,8 @@ fn from_dhall_value(uri: Option<&String>, value: serde_dhall::SimpleValue) -> Va
match value {
serde_dhall::SimpleValue::Num(num) => match num {
serde_dhall::NumKind::Bool(b) => Value::new(uri, ValueKind::Boolean(b)),
serde_dhall::NumKind::Natural(n) => Value::new(uri, ValueKind::Integer(n as i64)),
serde_dhall::NumKind::Integer(i) => Value::new(uri, ValueKind::Integer(i)),
serde_dhall::NumKind::Natural(n) => Value::new(uri, ValueKind::I64(n as i64)),
serde_dhall::NumKind::Integer(i) => Value::new(uri, ValueKind::I64(i)),
serde_dhall::NumKind::Double(d) => Value::new(uri, ValueKind::Float(f64::from(d))),
},
serde_dhall::SimpleValue::Text(string) => Value::new(uri, ValueKind::String(string)),
Expand Down

0 comments on commit 35a8b56

Please sign in to comment.