From 2af78fbabefec4bf254570ec8c2782ccc20b153a Mon Sep 17 00:00:00 2001 From: William Venner Date: Tue, 16 Mar 2021 03:42:11 +0000 Subject: Add ugc iter_maybe --- src/ugc.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/ugc.rs b/src/ugc.rs index d08b24d..bd8d935 100644 --- a/src/ugc.rs +++ b/src/ugc.rs @@ -844,8 +844,7 @@ impl<'a> QueryResults<'a> { let ok = sys::SteamAPI_ISteamUGC_GetQueryUGCResult(self.ugc, self.handle, index, &mut raw_details); debug_assert!(ok); - // TODO: is this always true? we don't get this from an async call... - debug_assert!(raw_details.m_eResult == sys::EResult::k_EResultOK); + if raw_details.m_eResult != sys::EResult::k_EResultOK { return None } let tags = CStr::from_ptr(raw_details.m_rgchTags.as_ptr()) .to_string_lossy() @@ -886,6 +885,12 @@ impl<'a> QueryResults<'a> { (0..self.returned_results()) .map(move |i| self.get(i).unwrap()) } + + /// Returns an iterator that runs over all the fetched results, but doesn't panic if one of those results failed + pub fn iter_maybe<'b>(&'b self) -> impl Iterator> + 'b { + (0..self.returned_results()) + .map(move |i| self.get(i)) + } } /// Query result -- cgit v1.2.3