Skip to content

Commit 2efc029

Browse files
committed
Remove Anyhow::Result in system_piping.rs example (#7657)
# Objective Fixes: #7610 ## Solution - Return a specific error type
1 parent 9dadde0 commit 2efc029

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

examples/ecs/system_piping.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
//! Illustrates how to make a single system from multiple functions running in sequence,
22
//! passing the output of the first into the input of the next.
33
4-
use anyhow::Result;
54
use bevy::prelude::*;
5+
use std::num::ParseIntError;
66

77
use bevy::log::LogPlugin;
88
use bevy::utils::tracing::Level;
@@ -31,20 +31,20 @@ struct Message(String);
3131
struct OptionalWarning(Result<(), String>);
3232

3333
// This system produces a Result<usize> output by trying to parse the Message resource.
34-
fn parse_message_system(message: Res<Message>) -> Result<usize> {
35-
Ok(message.parse::<usize>()?)
34+
fn parse_message_system(message: Res<Message>) -> Result<usize, ParseIntError> {
35+
message.parse::<usize>()
3636
}
3737

3838
// This system produces a Result<()> output by trying to parse the Message resource.
39-
fn parse_error_message_system(message: Res<Message>) -> Result<()> {
39+
fn parse_error_message_system(message: Res<Message>) -> Result<(), ParseIntError> {
4040
message.parse::<usize>()?;
4141
Ok(())
4242
}
4343

4444
// This system takes a Result<usize> input and either prints the parsed value or the error message
4545
// Try changing the Message resource to something that isn't an integer. You should see the error
4646
// message printed.
47-
fn handler_system(In(result): In<Result<usize>>) {
47+
fn handler_system(In(result): In<Result<usize, ParseIntError>>) {
4848
match result {
4949
Ok(value) => println!("parsed message: {value}"),
5050
Err(err) => println!("encountered an error: {err:?}"),

0 commit comments

Comments
 (0)