Part 2: Allow to Deref StructuredMap to the underlying IndexMap.

Again, this is a fundamental Rust pattern for newtypes.  It's awfully
hard to actually use `StructuredMap` without it!
This commit is contained in:
Nick Alexander 2018-06-18 14:52:16 -07:00
parent d49f702512
commit b9f3681728

View file

@ -15,6 +15,11 @@ use ::std::convert::{
use ::std::ffi::{
CString,
};
use ::std::ops::{
Deref,
};
use ::std::os::raw::c_char;
use ::std::rc::{
@ -342,6 +347,14 @@ impl Binding {
#[derive(Clone, Debug, Default, Eq, PartialEq)]
pub struct StructuredMap(pub IndexMap<ValueRc<Keyword>, Binding>);
impl Deref for StructuredMap {
type Target = IndexMap<ValueRc<Keyword>, Binding>;
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl StructuredMap {
pub fn insert<N, B>(&mut self, name: N, value: B) where N: Into<ValueRc<Keyword>>, B: Into<Binding> {
self.0.insert(name.into(), value.into());