pub trait VecHelper {
type Item;
// Required methods
fn find(&mut self, ident: PropertyIdent) -> Option<&mut Self::Item>;
fn find_or_insert<F>(
&mut self,
ident: PropertyIdent,
f: F,
) -> &mut Self::Item
where F: FnOnce(PropertyIdent) -> Self::Item;
}Expand description
Helper trait that implements additional methods for vectors.
Required Associated Types§
Required Methods§
Sourcefn find(&mut self, ident: PropertyIdent) -> Option<&mut Self::Item>
fn find(&mut self, ident: PropertyIdent) -> Option<&mut Self::Item>
Try to find the object with the passed ident in the vector. If it was
not found None is returned.
Sourcefn find_or_insert<F>(&mut self, ident: PropertyIdent, f: F) -> &mut Self::Item
fn find_or_insert<F>(&mut self, ident: PropertyIdent, f: F) -> &mut Self::Item
Try to find the object with the passed ident in the vector. If it was
not found, a new one is created by invoking f.
Returns a mutable reference either to the found or the newly created object.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".