pub struct Dict<'k, 'v> { /* private fields */ }
Expand description
Implementations§
source§impl<'k, 'v> Dict<'k, 'v>
impl<'k, 'v> Dict<'k, 'v>
sourcepub fn new(key_signature: Signature<'k>, value_signature: Signature<'v>) -> Self
pub fn new(key_signature: Signature<'k>, value_signature: Signature<'v>) -> Self
Create a new empty Dict
, given the signature of the keys and values.
sourcepub fn append<'kv: 'k, 'vv: 'v>(
&mut self,
key: Value<'kv>,
value: Value<'vv>
) -> Result<(), Error>
pub fn append<'kv: 'k, 'vv: 'v>( &mut self, key: Value<'kv>, value: Value<'vv> ) -> Result<(), Error>
Append key
and value
as a new entry.
Errors
- if
key.value_signature()
doesn’t match the key signatureself
was created for. - if
value.value_signature()
doesn’t match the value signatureself
was created for.
sourcepub fn add<K, V>(&mut self, key: K, value: V) -> Result<(), Error>where
K: Basic + Into<Value<'k>> + Hash + Eq,
V: Into<Value<'v>> + DynamicType,
pub fn add<K, V>(&mut self, key: K, value: V) -> Result<(), Error>where K: Basic + Into<Value<'k>> + Hash + Eq, V: Into<Value<'v>> + DynamicType,
Add a new entry.
sourcepub fn get<'d, K, V>(&'d self, key: &K) -> Result<Option<&'v V>, Error>where
K: ?Sized + Eq + 'k,
V: ?Sized,
&'k K: TryFrom<&'k Value<'k>>,
&'v V: TryFrom<&'v Value<'v>>,
'd: 'k + 'v,
pub fn get<'d, K, V>(&'d self, key: &K) -> Result<Option<&'v V>, Error>where K: ?Sized + Eq + 'k, V: ?Sized, &'k K: TryFrom<&'k Value<'k>>, &'v V: TryFrom<&'v Value<'v>>, 'd: 'k + 'v,
Get the value for the given key.
sourcepub fn signature(&self) -> Signature<'static>
pub fn signature(&self) -> Signature<'static>
Get the signature of this Dict
.
NB: This method potentially allocates and copies. Use full_signature
if you’d like to
avoid that.
sourcepub fn full_signature(&self) -> &Signature<'_>
pub fn full_signature(&self) -> &Signature<'_>
Get the signature of this Dict
.