Skip to content

Add print_err to ResultΒ #3900

@leaty

Description

@leaty

We have so many great functions to handle errors on a Result, but we have nothing to simply eprintln! it and go our merry way. Sometimes it's nice to always print the error (if any) without actually handling it.

This is one such example using channels for events:

tx.try_send(event)
	.inspect_err(|e| eprintln!("{e}"))
	.ok();

Could be just:

tx.try_send(event)
	.print_err()
	.ok();

I know it's not a huge deal, but the repetition of using the same exact format string every time got to me :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions