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.
This commit is contained in:
Cameron Cordes committed 2026-09-24 22:04:56 -04:00
1 parent 2f2107d4fa
commit 6f020f4201
1 file changed
+6 -2
+6 -2
View File
@@ -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::<i32, _>(42)
/// });
/// assert!(result.is_ok_and(|v| v == 42));
/// ```
pub fn retry_with_backoff_if<F, T, E, U: Fn(&E) -> bool>(
label: &str,