Skip to content

Commit e05aacc

Browse files
A6GibKmbilelmoussaoui
authored andcommitted
server: Simplify from_path methods
1 parent afe584d commit e05aacc

2 files changed

Lines changed: 2 additions & 14 deletions

File tree

server/src/collection.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -253,13 +253,7 @@ impl Collection {
253253
pub async fn item_from_path(&self, path: &ObjectPath<'_>) -> Option<item::Item> {
254254
let items = self.items.lock().await;
255255

256-
for item in items.iter() {
257-
if item.path() == path {
258-
return Some(item.clone());
259-
}
260-
}
261-
262-
None
256+
items.iter().find(|i| i.path() == path).cloned()
263257
}
264258

265259
pub async fn set_locked(&self, locked: bool) -> Result<(), ServiceError> {

server/src/service.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -457,13 +457,7 @@ impl Service {
457457
pub async fn collection_from_path(&self, path: &ObjectPath<'_>) -> Option<Collection> {
458458
let collections = self.collections.lock().await;
459459

460-
for collection in collections.iter() {
461-
if *collection.path() == **path {
462-
return Some(collection.clone());
463-
}
464-
}
465-
466-
None
460+
collections.iter().find(|c| c.path() == path).cloned()
467461
}
468462

469463
pub async fn session_index(&self) -> u32 {

0 commit comments

Comments
 (0)