This commit is contained in:
@@ -7,7 +7,7 @@ use crate::StringKey;
|
||||
|
||||
/// A data library is a collection of methods to set up a default library, where values are stored
|
||||
/// by both key, while keeping their insertion order.
|
||||
pub trait DataLibrary<'a, T: 'a> {
|
||||
pub trait DataLibrary<T: ?Sized> {
|
||||
/// Returns the underlying map.
|
||||
fn map(&self) -> &IndexMap<StringKey, Arc<T>>;
|
||||
/// Returns the underlying map in mutable manner.
|
||||
@@ -24,18 +24,18 @@ pub trait DataLibrary<'a, T: 'a> {
|
||||
}
|
||||
|
||||
/// Gets a value from the library.
|
||||
fn get(&'a self, key: &StringKey) -> Option<&Arc<T>> {
|
||||
fn get(&self, key: &StringKey) -> Option<&Arc<T>> {
|
||||
self.map().get::<StringKey>(key)
|
||||
}
|
||||
|
||||
/// Gets a value from the library.
|
||||
fn get_by_hash(&'a self, key: u32) -> Option<&Arc<T>> {
|
||||
fn get_by_hash(&self, key: u32) -> Option<&Arc<T>> {
|
||||
self.map().get::<u32>(&key)
|
||||
}
|
||||
|
||||
/// Gets a value from the library by the index where it is stored.
|
||||
fn get_key_by_index(&'a self, index: usize) -> Option<&StringKey> {
|
||||
self.map().get_index(index).map(|a| a.0)
|
||||
fn get_key_by_index(&self, index: usize) -> Option<StringKey> {
|
||||
self.map().get_index(index).map(|a| a.0.clone())
|
||||
}
|
||||
|
||||
/// Gets the amount of values in the library.
|
||||
|
||||
Reference in New Issue
Block a user