From 2efc0293ed7f04a8fc6422f60f69e26c517a5656 Mon Sep 17 00:00:00 2001 From: ZoOL Date: Tue, 14 Feb 2023 03:33:47 +0000 Subject: [PATCH] Remove Anyhow::Result in system_piping.rs example (#7657) # Objective Fixes: #7610 ## Solution - Return a specific error type --- examples/ecs/system_piping.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/ecs/system_piping.rs b/examples/ecs/system_piping.rs index da06a06408..cff592ff16 100644 --- a/examples/ecs/system_piping.rs +++ b/examples/ecs/system_piping.rs @@ -1,8 +1,8 @@ //! Illustrates how to make a single system from multiple functions running in sequence, //! passing the output of the first into the input of the next. -use anyhow::Result; use bevy::prelude::*; +use std::num::ParseIntError; use bevy::log::LogPlugin; use bevy::utils::tracing::Level; @@ -31,12 +31,12 @@ struct Message(String); struct OptionalWarning(Result<(), String>); // This system produces a Result output by trying to parse the Message resource. -fn parse_message_system(message: Res) -> Result { - Ok(message.parse::()?) +fn parse_message_system(message: Res) -> Result { + message.parse::() } // This system produces a Result<()> output by trying to parse the Message resource. -fn parse_error_message_system(message: Res) -> Result<()> { +fn parse_error_message_system(message: Res) -> Result<(), ParseIntError> { message.parse::()?; Ok(()) } @@ -44,7 +44,7 @@ fn parse_error_message_system(message: Res) -> Result<()> { // This system takes a Result input and either prints the parsed value or the error message // Try changing the Message resource to something that isn't an integer. You should see the error // message printed. -fn handler_system(In(result): In>) { +fn handler_system(In(result): In>) { match result { Ok(value) => println!("parsed message: {value}"), Err(err) => println!("encountered an error: {err:?}"),