mirror of
https://github.com/sagiegurari/duckscript
synced 2024-10-14 11:53:05 +00:00
Runtime - Support for hashset state value
This commit is contained in:
parent
a5457e636a
commit
1ef91e3fa7
|
@ -2,7 +2,6 @@
|
|||
|
||||
### v0.3.4
|
||||
|
||||
* \[Breaking Change\] Runtime - REPL mode doesn't stop due to crashes from user commands #103
|
||||
* New unset command.
|
||||
* New array_contains command.
|
||||
* New map_contains_value command.
|
||||
|
@ -10,6 +9,8 @@
|
|||
* New get_all_var_names command #100
|
||||
* New get_by_name command.
|
||||
* New set_by_name command.
|
||||
* Runtime - Support for hashset state value.
|
||||
* \[Breaking Change\] Runtime - REPL mode doesn't stop due to crashes from user commands #103
|
||||
|
||||
### v0.3.3 (2020-04-15)
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ use crate::types::command::Commands;
|
|||
use crate::types::instruction::Instruction;
|
||||
use std::any::Any;
|
||||
use std::cell::RefCell;
|
||||
use std::collections::HashMap;
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::rc::Rc;
|
||||
|
||||
/// enum defining what values can be stored in the state map
|
||||
|
@ -37,6 +37,8 @@ pub enum StateValue {
|
|||
ByteArray(Vec<u8>),
|
||||
/// list
|
||||
List(Vec<StateValue>),
|
||||
/// unique set of values
|
||||
Set(HashSet<StateValue>),
|
||||
/// sub state value
|
||||
SubState(HashMap<String, StateValue>),
|
||||
/// any value
|
||||
|
|
|
@ -160,6 +160,7 @@ pub(crate) fn get_as_string(state_value: &StateValue) -> Result<String, String>
|
|||
StateValue::String(value) => Ok(value.to_string()),
|
||||
StateValue::ByteArray(_) => Err("Unsupported value type.".to_string()),
|
||||
StateValue::List(_) => Err("Unsupported value type.".to_string()),
|
||||
StateValue::Set(_) => Err("Unsupported value type.".to_string()),
|
||||
StateValue::SubState(_) => Err("Unsupported value type.".to_string()),
|
||||
StateValue::Any(_) => Err("Unsupported value type.".to_string()),
|
||||
}
|
||||
|
@ -222,6 +223,10 @@ where
|
|||
state.insert(key, StateValue::List(value));
|
||||
Err("Invalid handle provided.".to_string())
|
||||
}
|
||||
StateValue::Set(value) => {
|
||||
state.insert(key, StateValue::Set(value));
|
||||
Err("Invalid handle provided.".to_string())
|
||||
}
|
||||
StateValue::Any(value) => {
|
||||
state.insert(key, StateValue::Any(value));
|
||||
Err("Invalid handle provided.".to_string())
|
||||
|
@ -284,6 +289,10 @@ where
|
|||
state.insert(key, StateValue::ByteArray(value));
|
||||
Err("Invalid handle provided.".to_string())
|
||||
}
|
||||
StateValue::Set(value) => {
|
||||
state.insert(key, StateValue::Set(value));
|
||||
Err("Invalid handle provided.".to_string())
|
||||
}
|
||||
StateValue::SubState(value) => {
|
||||
state.insert(key, StateValue::SubState(value));
|
||||
Err("Invalid handle provided.".to_string())
|
||||
|
|
Loading…
Reference in a new issue