diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-05-17 20:36:04 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-05-17 20:36:13 +0900 |
| commit | 07c1ef1aea3a0c60484fdada89de7c5a3b7cf7c6 (patch) | |
| tree | b8c6fc6692534ca5e9cf23ffcd5a53fcb3bce509 /crates/shirabe/src/dependency_resolver/rule.rs | |
| parent | 465a3a1bd96e15d7807d1bd05294299eee3427df (diff) | |
| download | php-shirabe-07c1ef1aea3a0c60484fdada89de7c5a3b7cf7c6.tar.gz php-shirabe-07c1ef1aea3a0c60484fdada89de7c5a3b7cf7c6.tar.zst php-shirabe-07c1ef1aea3a0c60484fdada89de7c5a3b7cf7c6.zip | |
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.
Diffstat (limited to 'crates/shirabe/src/dependency_resolver/rule.rs')
| -rw-r--r-- | crates/shirabe/src/dependency_resolver/rule.rs | 34 |
1 files changed, 19 insertions, 15 deletions
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<Request>, + reason_data: Option<ReasonData>, +} + +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), + } + } +} |
