Skip to content

Commit

Permalink
Testing pipe_in with generics
Browse files Browse the repository at this point in the history
  • Loading branch information
TGRCdev committed Feb 1, 2025
1 parent 04927f6 commit 71dc108
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion bevy-butler-proc-macro/src/system/structs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use syn::{Expr, Item, ItemUse};
use crate::utils;
use crate::utils::GenericOrMeta;

use self::utils::{parse_meta_args, parse_meta_args_with};
use self::utils::parse_meta_args_with;

#[derive(Clone)]
pub(crate) struct SystemAttr {
Expand Down
31 changes: 31 additions & 0 deletions bevy-butler/tests/system/generic_pipe.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
use std::fmt::Display;

use bevy::prelude::*;
use bevy_butler::*;

use crate::common::log_plugin;

#[butler_plugin]
struct MyPlugin;

#[derive(Resource)]
#[resource(plugin = MyPlugin, init = GenericRes(5u8))]
struct GenericRes<T>(T);

fn generic_pipe<T: 'static + Sync + Send + Display>(res: Res<GenericRes<T>>) -> String {
res.0.to_string()
}

#[system(plugin = MyPlugin, schedule = Startup, pipe_in = generic_pipe::<u8>)]
fn print_res(input: In<String>) {
info!("Generic resource: {}", input.0);
assert_eq!(input.0, "5");
}

#[test]
fn test() {
App::new()
.add_plugins(log_plugin())
.add_plugins(MyPlugin)
.run();
}
1 change: 1 addition & 0 deletions bevy-butler/tests/system/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ mod system;
mod system_expr_schedule;
mod use_declaration;
mod pipe;
mod generic_pipe;

0 comments on commit 71dc108

Please sign in to comment.