From 07c1ef1aea3a0c60484fdada89de7c5a3b7cf7c6 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sun, 17 May 2026 20:36:04 +0900 Subject: fix(compile): make Rule trait dyn-compatible by extracting RuleBase Removed the static fn new() from the Rule trait (which prevented dyn compatibility) and moved it into a new RuleBase struct. --- crates/shirabe/src/dependency_resolver/rule.rs | 34 ++++++++++++++------------ 1 file changed, 19 insertions(+), 15 deletions(-) (limited to 'crates/shirabe/src/dependency_resolver/rule.rs') diff --git a/crates/shirabe/src/dependency_resolver/rule.rs b/crates/shirabe/src/dependency_resolver/rule.rs index d1ec5c9..23a5981 100644 --- a/crates/shirabe/src/dependency_resolver/rule.rs +++ b/crates/shirabe/src/dependency_resolver/rule.rs @@ -67,21 +67,6 @@ pub trait Rule: std::fmt::Display { fn equals(&self, rule: &dyn Rule) -> bool; fn is_assertion(&self) -> bool; - /// @param self::RULE_* $reason A RULE_* constant describing the reason for generating this rule - /// @param mixed $reasonData - /// - /// @phpstan-param ReasonData $reasonData - fn new(reason: i64, reason_data: ReasonData) -> Self { - let bitfield = (0i64 << Self::BITFIELD_DISABLED) - | (reason << Self::BITFIELD_REASON) - | (255i64 << Self::BITFIELD_TYPE); - Self { - bitfield, - request: None, - reason_data, - } - } - /// @return self::RULE_* fn get_reason(&self) -> i64 { (self.bitfield & (255 << Self::BITFIELD_REASON)) >> Self::BITFIELD_REASON @@ -680,3 +665,22 @@ pub trait Rule: std::fmt::Display { package } } + +pub struct RuleBase { + bitfield: i64, + request: Option, + reason_data: Option, +} + +impl RuleBase { + fn new(reason: i64, reason_data: ReasonData) -> Self { + let bitfield = (0i64 << Self::BITFIELD_DISABLED) + | (reason << Self::BITFIELD_REASON) + | (255i64 << Self::BITFIELD_TYPE); + Self { + bitfield, + request: None, + reason_data: Some(reason_data), + } + } +} -- cgit v1.3.1