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:
parent
d49f702512
commit
b9f3681728
1 changed files with 13 additions and 0 deletions
|
@ -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());
|
||||
|
|
Loading…
Reference in a new issue