2019-06-29 22:02:27 +00:00
|
|
|
use std::hash::{Hash,Hasher};
|
|
|
|
use std::cmp::{Ordering};
|
|
|
|
use num::bigint::BigInt;
|
2019-09-09 13:46:53 +00:00
|
|
|
use std::rc::Rc;
|
|
|
|
use std::vec::Vec;
|
|
|
|
use std::string::String;
|
|
|
|
use std::collections::BTreeSet;
|
|
|
|
use std::collections::BTreeMap;
|
|
|
|
use std::ops::Index;
|
|
|
|
use std::ops::IndexMut;
|
2019-06-29 22:02:27 +00:00
|
|
|
|
2019-09-09 13:46:53 +00:00
|
|
|
/// The `Value`s from the specification.
|
2019-09-15 11:25:23 +00:00
|
|
|
#[derive(Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
|
2019-06-29 22:02:27 +00:00
|
|
|
pub enum Value {
|
|
|
|
Boolean(bool),
|
|
|
|
Float(Float),
|
|
|
|
Double(Double),
|
|
|
|
SignedInteger(BigInt),
|
2019-09-09 13:46:53 +00:00
|
|
|
String(String),
|
|
|
|
ByteString(Vec<u8>),
|
|
|
|
Symbol(String),
|
|
|
|
Record(Record),
|
|
|
|
Sequence(Vec<AValue>),
|
2019-09-09 21:08:26 +00:00
|
|
|
Set(Set),
|
|
|
|
Dictionary(Dictionary),
|
2019-06-29 22:02:27 +00:00
|
|
|
}
|
|
|
|
|
2019-09-09 13:46:53 +00:00
|
|
|
/// An possibly-annotated Value, with annotations (themselves
|
|
|
|
/// possibly-annotated) in order of appearance.
|
2019-09-15 11:25:23 +00:00
|
|
|
#[derive(Clone)]
|
2019-09-09 21:08:26 +00:00
|
|
|
pub struct AValue(pub Vec<AValue>, pub Value);
|
2019-09-09 13:46:53 +00:00
|
|
|
|
|
|
|
/// Single-precision IEEE 754 Value
|
2019-06-29 22:02:27 +00:00
|
|
|
#[derive(Clone, Debug)]
|
2019-09-09 21:08:26 +00:00
|
|
|
pub struct Float(pub f32);
|
2019-06-29 22:02:27 +00:00
|
|
|
|
2019-09-09 13:46:53 +00:00
|
|
|
/// Double-precision IEEE 754 Value
|
2019-06-29 22:02:27 +00:00
|
|
|
#[derive(Clone, Debug)]
|
2019-09-09 21:08:26 +00:00
|
|
|
pub struct Double(pub f64);
|
2019-06-29 22:02:27 +00:00
|
|
|
|
2019-09-09 13:46:53 +00:00
|
|
|
/// A Record `Value`
|
|
|
|
pub type Record = (Rc<AValue>, Vec<AValue>);
|
|
|
|
|
2019-09-09 21:08:26 +00:00
|
|
|
pub type Set = BTreeSet<AValue>;
|
|
|
|
|
|
|
|
pub type Dictionary = BTreeMap<AValue, AValue>;
|
|
|
|
|
2019-06-29 22:02:27 +00:00
|
|
|
impl From<f32> for Float {
|
|
|
|
fn from(v: f32) -> Self {
|
|
|
|
Float(v)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl From<Float> for f32 {
|
|
|
|
fn from(v: Float) -> Self {
|
|
|
|
v.0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Hash for Float {
|
|
|
|
fn hash<H: Hasher>(&self, state: &mut H) {
|
|
|
|
self.0.to_bits().hash(state);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl PartialEq for Float {
|
|
|
|
fn eq(&self, other: &Self) -> bool {
|
|
|
|
self.0.to_bits() == other.0.to_bits()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Ord for Float {
|
|
|
|
fn cmp(&self, other: &Self) -> Ordering {
|
2019-07-04 09:47:32 +00:00
|
|
|
let mut a: u32 = self.0.to_bits();
|
|
|
|
let mut b: u32 = other.0.to_bits();
|
2019-06-29 22:02:27 +00:00
|
|
|
if a & 0x80000000 != 0 { a ^= 0x7fffffff; }
|
|
|
|
if b & 0x80000000 != 0 { b ^= 0x7fffffff; }
|
2019-06-30 22:43:32 +00:00
|
|
|
(a as i32).cmp(&(b as i32))
|
2019-06-29 22:02:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl PartialOrd for Float {
|
|
|
|
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
|
|
|
|
Some(self.cmp(other))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Eq for Float {}
|
|
|
|
|
|
|
|
impl From<f64> for Double {
|
|
|
|
fn from(v: f64) -> Self {
|
|
|
|
Double(v)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl From<Double> for f64 {
|
|
|
|
fn from(v: Double) -> Self {
|
|
|
|
v.0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Hash for Double {
|
|
|
|
fn hash<H: Hasher>(&self, state: &mut H) {
|
|
|
|
self.0.to_bits().hash(state);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl PartialEq for Double {
|
|
|
|
fn eq(&self, other: &Self) -> bool {
|
|
|
|
return self.0.to_bits() == other.0.to_bits();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Ord for Double {
|
|
|
|
fn cmp(&self, other: &Self) -> Ordering {
|
2019-07-04 09:47:32 +00:00
|
|
|
let mut a: u64 = self.0.to_bits();
|
|
|
|
let mut b: u64 = other.0.to_bits();
|
2019-06-29 22:02:27 +00:00
|
|
|
if a & 0x8000000000000000 != 0 { a ^= 0x7fffffffffffffff; }
|
|
|
|
if b & 0x8000000000000000 != 0 { b ^= 0x7fffffffffffffff; }
|
2019-06-30 22:43:32 +00:00
|
|
|
(a as i64).cmp(&(b as i64))
|
2019-06-29 22:02:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl PartialOrd for Double {
|
|
|
|
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
|
|
|
|
Some(self.cmp(other))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Eq for Double {}
|
|
|
|
|
2019-09-09 13:46:53 +00:00
|
|
|
impl PartialEq for AValue {
|
|
|
|
fn eq(&self, other: &Self) -> bool {
|
|
|
|
self.1.eq(&other.1)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Eq for AValue {}
|
|
|
|
|
|
|
|
impl Hash for AValue {
|
|
|
|
fn hash<H: Hasher>(&self, state: &mut H) {
|
|
|
|
self.1.hash(state);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl PartialOrd for AValue {
|
|
|
|
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
|
|
|
|
Some(self.cmp(other))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Ord for AValue {
|
|
|
|
fn cmp(&self, other: &Self) -> Ordering {
|
|
|
|
self.1.cmp(&other.1)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-29 22:02:27 +00:00
|
|
|
impl From<bool> for Value { fn from(v: bool) -> Self { Value::Boolean(v) } }
|
|
|
|
|
|
|
|
impl From<f32> for Value { fn from(v: f32) -> Self { Value::Float(Float::from(v)) } }
|
|
|
|
impl From<f64> for Value { fn from(v: f64) -> Self { Value::Double(Double::from(v)) } }
|
|
|
|
|
|
|
|
impl From<u8> for Value { fn from(v: u8) -> Self { Value::SignedInteger(BigInt::from(v)) } }
|
|
|
|
impl From<i8> for Value { fn from(v: i8) -> Self { Value::SignedInteger(BigInt::from(v)) } }
|
|
|
|
impl From<u16> for Value { fn from(v: u16) -> Self { Value::SignedInteger(BigInt::from(v)) } }
|
|
|
|
impl From<i16> for Value { fn from(v: i16) -> Self { Value::SignedInteger(BigInt::from(v)) } }
|
|
|
|
impl From<u32> for Value { fn from(v: u32) -> Self { Value::SignedInteger(BigInt::from(v)) } }
|
|
|
|
impl From<i32> for Value { fn from(v: i32) -> Self { Value::SignedInteger(BigInt::from(v)) } }
|
|
|
|
impl From<u64> for Value { fn from(v: u64) -> Self { Value::SignedInteger(BigInt::from(v)) } }
|
|
|
|
impl From<i64> for Value { fn from(v: i64) -> Self { Value::SignedInteger(BigInt::from(v)) } }
|
|
|
|
impl From<u128> for Value { fn from(v: u128) -> Self { Value::SignedInteger(BigInt::from(v)) } }
|
|
|
|
impl From<i128> for Value { fn from(v: i128) -> Self { Value::SignedInteger(BigInt::from(v)) } }
|
|
|
|
impl From<BigInt> for Value { fn from(v: BigInt) -> Self { Value::SignedInteger(v) } }
|
|
|
|
|
|
|
|
impl From<&str> for Value { fn from(v: &str) -> Self { Value::String(String::from(v)) } }
|
|
|
|
impl From<String> for Value { fn from(v: String) -> Self { Value::String(v) } }
|
2019-09-09 13:46:53 +00:00
|
|
|
|
|
|
|
impl From<&[u8]> for Value { fn from(v: &[u8]) -> Self { Value::ByteString(Vec::from(v)) } }
|
|
|
|
impl From<Vec<u8>> for Value { fn from(v: Vec<u8>) -> Self { Value::ByteString(v) } }
|
|
|
|
|
2019-09-09 21:08:26 +00:00
|
|
|
impl From<Vec<AValue>> for Value { fn from(v: Vec<AValue>) -> Self { Value::Sequence(v) } }
|
|
|
|
|
2019-09-15 11:25:23 +00:00
|
|
|
impl std::fmt::Debug for Value {
|
|
|
|
// Not *quite* a formatter for the Preserves text syntax, since it
|
|
|
|
// doesn't escape strings/symbols properly.
|
|
|
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
|
|
match self {
|
|
|
|
Value::Boolean(false) => f.write_str("#false"),
|
2019-09-15 15:16:17 +00:00
|
|
|
Value::Boolean(true) => f.write_str("#true"),
|
2019-09-15 11:25:23 +00:00
|
|
|
Value::Float(Float(v)) => write!(f, "{:?}f", v),
|
|
|
|
Value::Double(Double(v)) => write!(f, "{:?}", v),
|
|
|
|
Value::SignedInteger(v) => write!(f, "{}", v),
|
|
|
|
Value::String(ref v) => write!(f, "{:?}", v), // TODO: proper escaping!
|
|
|
|
Value::ByteString(ref v) => {
|
|
|
|
f.write_str("#hex{")?;
|
|
|
|
for b in v { write!(f, "{:02x}", b)? }
|
|
|
|
f.write_str("}")
|
|
|
|
}
|
|
|
|
Value::Symbol(ref v) => {
|
|
|
|
// TODO: proper escaping!
|
|
|
|
if v.len() == 0 {
|
|
|
|
f.write_str("||")
|
|
|
|
} else {
|
|
|
|
write!(f, "{}", v)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Value::Record((ref l, ref fs)) => {
|
|
|
|
f.write_str("<")?;
|
|
|
|
l.fmt(f)?;
|
|
|
|
for v in fs {
|
|
|
|
f.write_str(" ")?;
|
|
|
|
v.fmt(f)?;
|
|
|
|
}
|
|
|
|
f.write_str(">")
|
|
|
|
}
|
|
|
|
Value::Sequence(ref v) => v.fmt(f),
|
|
|
|
Value::Set(ref v) => {
|
|
|
|
f.write_str("#set")?;
|
|
|
|
f.debug_set().entries(v.iter()).finish()
|
|
|
|
}
|
|
|
|
Value::Dictionary (ref v) => f.debug_map().entries(v.iter()).finish()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl std::fmt::Debug for AValue {
|
|
|
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
|
|
for ann in &self.0 {
|
|
|
|
write!(f, "@{:?} ", ann)?;
|
|
|
|
}
|
|
|
|
self.1.fmt(f)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-09 13:46:53 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
impl AValue {
|
|
|
|
pub fn rc(self) -> Rc<Self> {
|
|
|
|
Rc::new(self)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn annotations(&self) -> &Vec<AValue> {
|
|
|
|
&self.0
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn annotations_mut(&mut self) -> &mut Vec<AValue> {
|
|
|
|
&mut self.0
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn value(&self) -> &Value {
|
|
|
|
&self.1
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn value_mut(&mut self) -> &mut Value {
|
|
|
|
&mut self.1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Value {
|
|
|
|
pub fn wrap(self) -> AValue {
|
|
|
|
AValue(Vec::new(), self)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn is_boolean(&self) -> bool {
|
|
|
|
self.as_boolean().is_some()
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn as_boolean(&self) -> Option<bool> {
|
|
|
|
if let Value::Boolean(b) = *self {
|
|
|
|
Some(b)
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn as_boolean_mut(&mut self) -> Option<&mut bool> {
|
|
|
|
if let Value::Boolean(ref mut b) = *self {
|
|
|
|
Some(b)
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn is_float(&self) -> bool {
|
|
|
|
self.as_float().is_some()
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn as_float(&self) -> Option<f32> {
|
|
|
|
if let Value::Float(Float(f)) = *self {
|
|
|
|
Some(f)
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn as_float_mut(&mut self) -> Option<&mut f32> {
|
|
|
|
if let Value::Float(Float(ref mut f)) = *self {
|
|
|
|
Some(f)
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn is_double(&self) -> bool {
|
|
|
|
self.as_double().is_some()
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn as_double(&self) -> Option<f64> {
|
|
|
|
if let Value::Double(Double(f)) = *self {
|
|
|
|
Some(f)
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn as_double_mut(&mut self) -> Option<&mut f64> {
|
|
|
|
if let Value::Double(Double(ref mut f)) = *self {
|
|
|
|
Some(f)
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn is_signedinteger(&self) -> bool {
|
|
|
|
self.as_signedinteger().is_some()
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn as_signedinteger(&self) -> Option<&BigInt> {
|
|
|
|
if let Value::SignedInteger(ref i) = *self {
|
|
|
|
Some(i)
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn as_signedinteger_mut(&mut self) -> Option<&mut BigInt> {
|
|
|
|
if let Value::SignedInteger(ref mut i) = *self {
|
|
|
|
Some(i)
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn is_string(&self) -> bool {
|
|
|
|
self.as_string().is_some()
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn as_string(&self) -> Option<&String> {
|
|
|
|
if let Value::String(ref s) = *self {
|
|
|
|
Some(s)
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn as_string_mut(&mut self) -> Option<&mut String> {
|
|
|
|
if let Value::String(ref mut s) = *self {
|
|
|
|
Some(s)
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn is_bytestring(&self) -> bool {
|
|
|
|
self.as_bytestring().is_some()
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn as_bytestring(&self) -> Option<&Vec<u8>> {
|
|
|
|
if let Value::ByteString(ref s) = *self {
|
|
|
|
Some(s)
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn as_bytestring_mut(&mut self) -> Option<&mut Vec<u8>> {
|
|
|
|
if let Value::ByteString(ref mut s) = *self {
|
|
|
|
Some(s)
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn symbol(s: &str) -> Value {
|
|
|
|
Value::Symbol(s.to_string())
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn is_symbol(&self) -> bool {
|
|
|
|
self.as_symbol().is_some()
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn as_symbol(&self) -> Option<&String> {
|
|
|
|
if let Value::Symbol(ref s) = *self {
|
|
|
|
Some(s)
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn as_symbol_mut(&mut self) -> Option<&mut String> {
|
|
|
|
if let Value::Symbol(ref mut s) = *self {
|
|
|
|
Some(s)
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn record(label: &Rc<AValue>, fields: Vec<AValue>) -> Value {
|
|
|
|
Value::Record((Rc::clone(label), fields))
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn is_record(&self) -> bool {
|
|
|
|
self.as_record().is_some()
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn as_record(&self) -> Option<&Record> {
|
|
|
|
if let Value::Record(ref r) = *self {
|
|
|
|
Some(r)
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn as_record_mut(&mut self) -> Option<&mut Record> {
|
|
|
|
if let Value::Record(ref mut r) = *self {
|
|
|
|
Some(r)
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn is_sequence(&self) -> bool {
|
|
|
|
self.as_sequence().is_some()
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn as_sequence(&self) -> Option<&Vec<AValue>> {
|
|
|
|
if let Value::Sequence(ref s) = *self {
|
|
|
|
Some(s)
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn as_sequence_mut(&mut self) -> Option<&mut Vec<AValue>> {
|
|
|
|
if let Value::Sequence(ref mut s) = *self {
|
|
|
|
Some(s)
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn is_set(&self) -> bool {
|
|
|
|
self.as_set().is_some()
|
|
|
|
}
|
|
|
|
|
2019-09-09 21:08:26 +00:00
|
|
|
pub fn as_set(&self) -> Option<&Set> {
|
2019-09-09 13:46:53 +00:00
|
|
|
if let Value::Set(ref s) = *self {
|
|
|
|
Some(s)
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-09 21:08:26 +00:00
|
|
|
pub fn as_set_mut(&mut self) -> Option<&mut Set> {
|
2019-09-09 13:46:53 +00:00
|
|
|
if let Value::Set(ref mut s) = *self {
|
|
|
|
Some(s)
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn is_dictionary(&self) -> bool {
|
|
|
|
self.as_dictionary().is_some()
|
|
|
|
}
|
|
|
|
|
2019-09-09 21:08:26 +00:00
|
|
|
pub fn as_dictionary(&self) -> Option<&Dictionary> {
|
2019-09-09 13:46:53 +00:00
|
|
|
if let Value::Dictionary(ref s) = *self {
|
|
|
|
Some(s)
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-09 21:08:26 +00:00
|
|
|
pub fn as_dictionary_mut(&mut self) -> Option<&mut Dictionary> {
|
2019-09-09 13:46:53 +00:00
|
|
|
if let Value::Dictionary(ref mut s) = *self {
|
|
|
|
Some(s)
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Index<usize> for Value {
|
|
|
|
type Output = AValue;
|
|
|
|
|
|
|
|
fn index(&self, i: usize) -> &Self::Output {
|
|
|
|
&self.as_sequence().unwrap()[i]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl IndexMut<usize> for Value {
|
|
|
|
fn index_mut(&mut self, i: usize) -> &mut Self::Output {
|
|
|
|
&mut self.as_sequence_mut().unwrap()[i]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Index<&AValue> for Value {
|
|
|
|
type Output = AValue;
|
|
|
|
|
|
|
|
fn index(&self, i: &AValue) -> &Self::Output {
|
|
|
|
&self.as_dictionary().unwrap()[i]
|
|
|
|
}
|
|
|
|
}
|