pub trait ObjectTrait {
type Key: ?Sized;
type Element;
// Required methods
fn get<Q>(&self, k: &Q) -> Option<&Self::Element>
where Self::Key: Borrow<Q>,
Q: Hash + Eq + Ord + ?Sized;
fn iter<'i>(
&'i self,
) -> Box<dyn Iterator<Item = (&'i Self::Key, &'i Self::Element)> + 'i>;
fn keys<'i>(&'i self) -> Box<dyn Iterator<Item = &'i Self::Key> + 'i>;
fn values<'i>(&'i self) -> Box<dyn Iterator<Item = &'i Self::Element> + 'i>;
fn len(&self) -> usize;
// Provided method
fn is_empty(&self) -> bool { ... }
}
Expand description
A trait for the minimal common functionality of a vale object
Required Associated Types§
Required Methods§
Sourcefn get<Q>(&self, k: &Q) -> Option<&Self::Element>
fn get<Q>(&self, k: &Q) -> Option<&Self::Element>
Gets a ref to a value based on a key, returns None
if the
current Value isn’t an Object or doesn’t contain the key
it was asked for.
Sourcefn iter<'i>(
&'i self,
) -> Box<dyn Iterator<Item = (&'i Self::Key, &'i Self::Element)> + 'i>
fn iter<'i>( &'i self, ) -> Box<dyn Iterator<Item = (&'i Self::Key, &'i Self::Element)> + 'i>
Iterates over the key value paris
Provided Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.