From c0fe8649232fa51b97ead1591b78f7ebf727c80f Mon Sep 17 00:00:00 2001 From: kjuulh Date: Sat, 30 Mar 2024 23:39:14 +0100 Subject: [PATCH] feat: with as ref as well Signed-off-by: kjuulh --- crates/cuddle-ci/src/cli.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/crates/cuddle-ci/src/cli.rs b/crates/cuddle-ci/src/cli.rs index 49d8500..953615f 100644 --- a/crates/cuddle-ci/src/cli.rs +++ b/crates/cuddle-ci/src/cli.rs @@ -43,22 +43,26 @@ impl CuddleCI { } } - pub fn with_pull_request(&mut self, pr: T) -> &mut Self + pub fn with_pull_request(&mut self, pr: impl AsRef) -> &mut Self where T: PullRequestAction + ToOwned + Send + Sync + 'static, T: ToOwned, { + let pr = pr.as_ref(); + self.pr_action.push(Box::new(pr.to_owned())); self } - pub fn with_main(&mut self, main: T) -> &mut Self + pub fn with_main(&mut self, main: impl AsRef) -> &mut Self where T: MainAction + Send + Sync + 'static, T: ToOwned, { - self.main_action.push(Box::new(main)); + let main = main.as_ref(); + + self.main_action.push(Box::new(main.to_owned())); self }