From 2298b04eecb822fbbd7ce7ec9615ab15af08dec9 Mon Sep 17 00:00:00 2001 From: Adam Cooper Date: Wed, 16 Feb 2022 09:17:43 -0500 Subject: [PATCH] [wip] Committing before starting over Committing before duplicating the file and rewriting it line by line with more careful attention to the borrow checker. --- src/main.rs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index ec12590..7c8d783 100644 --- a/src/main.rs +++ b/src/main.rs @@ -133,9 +133,9 @@ async fn traverse(mut result: Multistatus) { let mut already_visited: bool; // Initialize the hashmap of visited items (by etag?) let mut visited_items = HashMap::new(); - // match result.response[0].propstat[0].prop { - match &result.response.into_iter().nth(0).unwrap() - .propstat.into_iter().nth(0).unwrap().prop { + /* + match result.response[0].propstat[0].prop { + // match result.response.get(0).unwrap().propstat.get(0).unwrap().prop { Some(prop) => match prop.get_etag { Some(etag) => { visited_items.insert(etag, true); @@ -145,8 +145,19 @@ async fn traverse(mut result: Multistatus) { }, _ => current_index += 1, } + */ + if let Some(prop) = &result.response[0].propstat[0].prop { + if let Some(etag) = &prop.get_etag { + visited_items.insert(etag, true); + } else { + current_index += 1; + } + } else { + current_index += 1; + } + // Depth first traversal - while !result.response.is_empty() { + while current_index < &result.response.len() { match &result.response[current_index].propstat[0].prop { Some(prop) => { match prop.get_etag {