chore: rename list_by_class to list
This commit is contained in:
@@ -131,7 +131,7 @@ fn main() {
|
||||
new_catalog.load_by_filter(&filter).unwrap();
|
||||
// Get the list of loaded components.
|
||||
let loaded_components: Vec<Component> = new_catalog
|
||||
.list_by_class::<Component>()
|
||||
.list::<Component>()
|
||||
.unwrap()
|
||||
.into_iter()
|
||||
.map(|c| c.unwrap())
|
||||
|
||||
@@ -142,7 +142,7 @@ fn main() -> Result<(), FailedTo> {
|
||||
laptop_catalog.load_by_filter(&laptop_filter)?;
|
||||
|
||||
let laptops: Vec<Product> = laptop_catalog
|
||||
.list_by_class()
|
||||
.list()
|
||||
.unwrap()
|
||||
.into_iter()
|
||||
.map(|p| p.unwrap())
|
||||
@@ -170,7 +170,7 @@ fn main() -> Result<(), FailedTo> {
|
||||
expensive_catalog.load_by_filter(&expensive_filter)?;
|
||||
|
||||
let expensive_products: Vec<Product> = expensive_catalog
|
||||
.list_by_class()
|
||||
.list()
|
||||
.unwrap()
|
||||
.into_iter()
|
||||
.map(|p| p.unwrap())
|
||||
@@ -202,7 +202,7 @@ fn main() -> Result<(), FailedTo> {
|
||||
all_products_catalog.load_by_filter(&all_products_filter)?;
|
||||
|
||||
let all_products: Vec<Product> = all_products_catalog
|
||||
.list_by_class()
|
||||
.list()
|
||||
.unwrap()
|
||||
.into_iter()
|
||||
.map(|p| p.unwrap())
|
||||
|
||||
@@ -20,7 +20,7 @@ impl Catalog {
|
||||
///
|
||||
/// Returns `Err(FailedTo::LockCatalog)` if the catalog's internal mutex
|
||||
/// could not be locked.
|
||||
pub fn list_by_class<T>(&self) -> Result<Vec<Result<T, FailedTo>>, FailedTo>
|
||||
pub fn list<T>(&self) -> Result<Vec<Result<T, FailedTo>>, FailedTo>
|
||||
where
|
||||
T: EAV,
|
||||
{
|
||||
@@ -10,7 +10,7 @@ pub mod catalog_init;
|
||||
pub mod catalog_insert_many;
|
||||
pub mod catalog_is_empty;
|
||||
pub mod catalog_len;
|
||||
pub mod catalog_list_by_class;
|
||||
pub mod catalog_list;
|
||||
pub mod catalog_list_by_subclass;
|
||||
pub mod catalog_load;
|
||||
pub mod catalog_load_by_filter;
|
||||
|
||||
@@ -71,7 +71,7 @@ mod tests {
|
||||
let mut catalog2 = Catalog::new(db_path);
|
||||
catalog2.load::<Item>().unwrap();
|
||||
let mut loaded_items: Vec<Item> = catalog2
|
||||
.list_by_class::<Item>()
|
||||
.list::<Item>()
|
||||
.unwrap()
|
||||
.into_iter()
|
||||
.map(|item| item.unwrap())
|
||||
|
||||
@@ -25,7 +25,7 @@ mod tests {
|
||||
};
|
||||
let _ = catalog.upsert(item1.clone());
|
||||
let _ = catalog.upsert(item2.clone());
|
||||
let results = catalog.list_by_class::<Item>().unwrap();
|
||||
let results = catalog.list::<Item>().unwrap();
|
||||
assert_eq!(results.len(), 2);
|
||||
assert!(results.contains(&Ok(item1)));
|
||||
assert!(results.contains(&Ok(item2)));
|
||||
@@ -34,7 +34,7 @@ mod tests {
|
||||
fn list_by_class_should_return_empty_iterator_if_no_match() {
|
||||
// Should return an empty iterator if no entities of that class exist.
|
||||
let catalog = Catalog::new("dummy.db");
|
||||
let results: Vec<_> = catalog.list_by_class::<Item>().unwrap();
|
||||
let results: Vec<_> = catalog.list::<Item>().unwrap();
|
||||
assert!(results.is_empty());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user