Skip to content

Commit

Permalink
Merge commit '6389c1c56fc083d31e6b8a3f0f3a1a842418682d'
Browse files Browse the repository at this point in the history
  • Loading branch information
phorward committed Apr 26, 2022
2 parents 893959c + 6389c1c commit 3284d28
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 3 deletions.
23 changes: 23 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ tokay = "0.4"
glob = "0.3.0"

[dependencies]
indexmap = "1.8.1"
macros = { path = "macros" }
clap = { version = "2", features = ["yaml"] }
rustyline = "8.2.0"
Expand Down
20 changes: 17 additions & 3 deletions src/value/dict.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
//! Dictionary object
use super::{BoxedObject, Object, RefValue};
use indexmap::IndexMap;
use macros::tokay_method;
use std::collections::BTreeMap;

// Alias for the inner dict
type InnerDict = BTreeMap<String, RefValue>;
type InnerDict = IndexMap<String, RefValue>;

// Dict object type
#[derive(Debug, Clone, PartialEq, PartialOrd)]
#[derive(Debug, Clone, PartialEq)]
pub struct Dict {
dict: InnerDict,
}
Expand Down Expand Up @@ -132,6 +132,12 @@ impl Dict {
*/
}

impl PartialOrd for Dict {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
todo!();
}
}

impl std::ops::Deref for Dict {
type Target = InnerDict;

Expand All @@ -152,6 +158,14 @@ impl From<Dict> for RefValue {
}
}

#[test]
fn test_dict() {
assert_eq!(
crate::utils::compile_and_run("(b => 3, c => 1, a => 2)", ""),
Ok(Some(crate::value!(["a" => 2, "b" => 3, "c" => 1])))
);
}

#[test]
fn test_dict_len() {
assert_eq!(
Expand Down
2 changes: 2 additions & 0 deletions src/value/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ impl PartialEq<&Self> for BoxedObject {
}
}

impl Eq for BoxedObject {}

// PartialOrdBoxedObject
// ----------------------------------------------------------------------------

Expand Down

0 comments on commit 3284d28

Please sign in to comment.