-
I'm trying to create a These two systems are, for example, as follows. fn get_config_path() -> Option<PathBuf> { todo!() }
fn load_config(In(_path): In<PathBuf>) {} To achieve this, I wrote the following code: use std::{borrow::Cow, path::PathBuf};
use bevy::{
ecs::system::{CombinatorSystem, Combine},
prelude::*,
};
pub type AndThenPipeSystem<SystemA, SystemB> =
CombinatorSystem<AndThenPipeMarker, SystemA, SystemB>;
#[doc(hidden)]
pub struct AndThenPipeMarker;
impl<SystemA, SystemB, T> Combine<SystemA, SystemB> for AndThenPipeMarker
where
SystemA: System<Out = Option<T>>,
SystemB: System,
for<'a> SystemB::In: SystemInput<Inner<'a> = T>,
{
type In = SystemA::In;
type Out = Option<SystemB::Out>;
fn combine(
input: <Self::In as SystemInput>::Inner<'_>,
a: impl FnOnce(SystemIn<'_, SystemA>) -> <SystemA as System>::Out,
b: impl FnOnce(SystemIn<'_, SystemB>) -> <SystemB as System>::Out,
) -> Self::Out {
a(input).map(b)
}
}
fn get_config_path() -> Option<PathBuf> {
todo!();
}
fn load_config(In(_path): In<PathBuf>) {}
fn main() {
let mut app = App::new();
app.add_systems(
Startup,
AndThenPipeSystem::new(get_config_path, load_config, Cow::Borrowed("AndThenPipe")),
);
} And the following error occurred:
How can I implement it correctly? What am I missing? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 6 replies
-
I believe you're at least missing an implementation of That being said, your implementation of Finally, I don't know if you're aware but you can achieve what you want with fn get_config_path() -> Option<PathBuf> {
todo!()
}
fn load_config(In(maybe_path): In<Option<PathBuf>>) {
let Some(_path) = maybe_path else {
return;
};
todo!()
}
fn main() {
let mut app = App::new();
app.add_systems(Startup, get_config_path.pipe(load_config));
} |
Beta Was this translation helpful? Give feedback.
Refer to IntoPipeSystem (v0.16.1) to implement
IntoAndThenPipeSystem
.