From 6f020f42015f19cf124890aec06a400dbeeae8b5 Mon Sep 17 00:00:00 2001 From: Cameron Cordes Date: Thu, 24 Sep 2026 22:04:56 -0400 Subject: [PATCH] docs(utils): make the retry_with_backoff_if doctest actually compile The example referenced an unimported DbError whose type didn't even match the closure's anyhow::Error, and the classifier body returned (). Rewritten as a self-contained io::Error example with an assertion. --- src/utils.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/utils.rs b/src/utils.rs index 6439d2a..8a44b46 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -63,11 +63,15 @@ where /// ``` /// use image_api::utils::retry_with_backoff_if; /// -/// fn is_transient(e: &DbError) -> bool { /* ... */ } +/// fn is_transient(e: &std::io::Error) -> bool { +/// // Only retry connection-class failures; a NotFound is deterministic. +/// e.kind() == std::io::ErrorKind::ConnectionRefused +/// } /// /// let result = retry_with_backoff_if("some-write", 4, is_transient, || { -/// Ok::<_, anyhow::Error>(42) +/// Ok::(42) /// }); +/// assert!(result.is_ok_and(|v| v == 42)); /// ``` pub fn retry_with_backoff_if bool>( label: &str,