duck_back 1.0.0

Options and results are water off a duck's back.
Documentation
  • Coverage
  • 100%
    6 out of 6 items documented1 out of 5 items with examples
  • Size
  • Source code size: 56.42 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 3.13 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 2m 43s Average build duration of successful builds.
  • all releases: 2m 43s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • coolcatcoder/duck_back
    1 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • coolcatcoder

Water Off a Duck's Back

Description:

Allows for easy error handling in bevy.

Warning: Darkness

This crate requires nightly, as it uses try_trait_v2 to convert from results and options to () using the ? operator.
It also uses try_as_dyn in order to prefer Display to Debug implementations when displaying an error.
I have little doubt that eventually in some form these features will be stabilised.

Example:

use bevy::{log::LogPlugin, prelude::*};
use duck_back::Else;

fn main() {
    App::new()
        .add_plugins(DefaultPlugins.set(LogPlugin {
            filter: "duck_back=trace".to_string(),
            ..default()
        }))
        .add_systems(Startup, (start, query))
        .run();
}

fn start() {
    let bad: Option<u32> = None;
    let _bad: u32 = bad.else_return()?;
}

fn query(transform: Query<&Transform>) {
    let _transform: &Transform = transform.single().else_error()?;
}
2026-02-16T05:05:12.958909Z ERROR duck_back: (examples/messages.rs:20:5)
Failed to unwrap value.
No entities fit the query bevy_ecs::system::query::Query<'_, '_, &bevy_transform::components::transform::Transform>
2026-02-16T05:05:12.958934Z TRACE duck_back: (examples/messages.rs:16:5)
Failed to unwrap value.