tokay-lang / tokay

Tokay is a programming language designed for ad-hoc parsing, inspired by awk.
https://tokay.dev
MIT License
239 stars 7 forks source link

Implement `dict` as `IndexMap<RefValue, RefValue>` when key is not mutable #79

Closed phorward closed 1 year ago

phorward commented 1 year ago

8d14573d36c82afca15ef7d8d04450cb2858c0de introduces Object::is_mutable(). This can be used to implement keys of dict as RefValue as well, instead of just String.

src/value/dict2.rs was already a test-facility on this:

//! Test stub for a Dict type that uses RefValue as key
/// This shall become standard in combination with the is_mutable() flag

use super::{BoxedObject, Object, RefValue};
use indexmap::IndexMap;

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

// Dict object type
#[derive(Debug, Clone, PartialEq)]
pub struct Dict {
    dict: InnerDict,
}

Things to do:

phorward commented 1 year ago

Closed by #96