edit in beancount/types/src/lib.rs at line 19
+ pub use crate::directive::Interface as DirectiveInterface;
edit in beancount/types/src/directive.rs at line 4
+ use enum_dispatch::enum_dispatch;
edit in beancount/types/src/directive.rs at line 17
+
+ use self::seal::Sealed;
edit in beancount/types/src/directive.rs at line 25
+
+ mod seal {
+ #[enum_dispatch::enum_dispatch]
+ pub trait Sealed {}
+ }
edit in beancount/types/src/directive.rs at line 31
+ #[enum_dispatch(Interface, Sealed)]
replacement in beancount/types/src/directive.rs at line 35
[2.9075]→[2.9075:9179](∅→∅) − Balance(Balance),
− Close(Close),
− Open(Open),
− Price(Price),
− Transaction(Transaction),
+ Balance,
+ Close,
+ Open,
+ Price,
+ Transaction,
edit in beancount/types/src/directive.rs at line 71
[2.9886]→[2.9886:10174](∅→∅),
[2.10174]→[2.10174:10220](∅→∅),
[2.10220]→[2.10220:10406](∅→∅) − delegate! {
− to match self {
− Self::Balance(inner) => inner,
− Self::Close(inner) => inner,
− Self::Open(inner) => inner,
− Self::Price(inner) => inner,
− Self::Transaction(inner) => inner,
− } {
− #[must_use]
− pub const fn date(&self) -> Date;
−
− #[must_use]
− pub fn main_account(&self) -> Option<&Acc>;
−
− #[must_use]
− pub fn timestamp(&self) -> Option<OffsetDateTime>;
− }
− }
−
replacement in beancount/types/src/directive.rs at line 91
[2.10894]→[2.10894:10996](∅→∅),
[2.10996]→[2.10996:11004](∅→∅),
[2.11004]→[2.11004:11005](∅→∅),
[2.11005]→[2.11005:11109](∅→∅),
[2.11109]→[2.11109:11110](∅→∅),
[2.11110]→[2.11110:11211](∅→∅) − impl From<Balance> for Directive {
− fn from(value: Balance) -> Self {
− Self::Balance(value)
− }
− }
−
− impl From<Close> for Directive {
− fn from(value: Close) -> Self {
− Self::Close(value)
− }
− }
−
− impl From<Open> for Directive {
− fn from(value: Open) -> Self {
− Self::Open(value)
− }
− }
+ #[enum_dispatch]
+ pub trait Interface: Sealed {
+ #[must_use]
+ fn date(&self) -> Date;
replacement in beancount/types/src/directive.rs at line 96
[2.11212]→[2.11212:11314](∅→∅),
[2.11314]→[2.11314:11316](∅→∅) − impl From<Price> for Directive {
− fn from(value: Price) -> Self {
− Self::Price(value)
− }
− }
+ #[must_use]
+ fn main_account(&self) -> Option<&Acc>;
replacement in beancount/types/src/directive.rs at line 99
[2.11317]→[2.11317:11437](∅→∅) − impl From<Transaction> for Directive {
− fn from(value: Transaction) -> Self {
− Self::Transaction(value)
− }
+ #[must_use]
+ fn timestamp(&self) -> Option<OffsetDateTime>;
replacement in beancount/types/src/directive/transaction.rs at line 335
[3.2107]→[3.10207:10226](∅→∅) + impl super::Interface for Transaction {
replacement in beancount/types/src/directive/transaction.rs at line 338
[3.91793046]→[2.77268:77307](∅→∅) − pub const fn date(&self) -> Date {
+ fn date(&self) -> Date {
replacement in beancount/types/src/directive/transaction.rs at line 344
[2.77362]→[3.91793046:91793095](∅→∅),
[3.91793046]→[3.91793046:91793095](∅→∅) − pub fn main_account(&self) -> Option<&Acc> {
+ fn main_account(&self) -> Option<&Acc> {
replacement in beancount/types/src/directive/transaction.rs at line 352
[2.77379]→[3.112:168](∅→∅),
[3.112]→[3.112:168](∅→∅) − pub fn timestamp(&self) -> Option<OffsetDateTime> {
+ fn timestamp(&self) -> Option<OffsetDateTime> {
edit in beancount/types/src/directive/transaction.rs at line 396
+
+ impl super::seal::Sealed for Transaction {}
replacement in beancount/types/src/directive/price.rs at line 81
[2.77579]→[2.77579:77592](∅→∅) + impl super::Interface for Price {
replacement in beancount/types/src/directive/price.rs at line 84
[2.77622]→[2.77622:77661](∅→∅) − pub const fn date(&self) -> Date {
+ fn date(&self) -> Date {
replacement in beancount/types/src/directive/price.rs at line 90
[2.77716]→[2.77716:77771](∅→∅) − pub const fn main_account(&self) -> Option<&Acc> {
+ fn main_account(&self) -> Option<&Acc> {
replacement in beancount/types/src/directive/price.rs at line 96
[2.77821]→[2.77821:77877](∅→∅) − pub fn timestamp(&self) -> Option<OffsetDateTime> {
+ fn timestamp(&self) -> Option<OffsetDateTime> {
edit in beancount/types/src/directive/price.rs at line 121
+
+ impl super::seal::Sealed for Price {}
replacement in beancount/types/src/directive/open.rs at line 115
[3.3096]→[3.3096:3108](∅→∅) + impl super::Interface for Open {
replacement in beancount/types/src/directive/open.rs at line 118
[2.78347]→[2.78347:78386](∅→∅) − pub const fn date(&self) -> Date {
+ fn date(&self) -> Date {
replacement in beancount/types/src/directive/open.rs at line 124
[2.78441]→[2.78441:78490](∅→∅) − pub fn main_account(&self) -> Option<&Acc> {
+ fn main_account(&self) -> Option<&Acc> {
replacement in beancount/types/src/directive/open.rs at line 130
[3.3138]→[3.3138:3194](∅→∅) − pub fn timestamp(&self) -> Option<OffsetDateTime> {
+ fn timestamp(&self) -> Option<OffsetDateTime> {
edit in beancount/types/src/directive/open.rs at line 164
+
+ impl super::seal::Sealed for Open {}
replacement in beancount/types/src/directive/close.rs at line 75
[3.1715]→[3.1715:1728](∅→∅) + impl super::Interface for Close {
replacement in beancount/types/src/directive/close.rs at line 78
[2.78966]→[2.78966:79005](∅→∅) − pub const fn date(&self) -> Date {
+ fn date(&self) -> Date {
replacement in beancount/types/src/directive/close.rs at line 84
[2.79060]→[2.79060:79109](∅→∅) − pub fn main_account(&self) -> Option<&Acc> {
+ fn main_account(&self) -> Option<&Acc> {
replacement in beancount/types/src/directive/close.rs at line 90
[3.1758]→[3.1758:1814](∅→∅) − pub fn timestamp(&self) -> Option<OffsetDateTime> {
+ fn timestamp(&self) -> Option<OffsetDateTime> {
edit in beancount/types/src/directive/close.rs at line 114
+
+ impl super::seal::Sealed for Close {}
replacement in beancount/types/src/directive/balance.rs at line 81
[3.13179]→[3.13179:13194](∅→∅) + impl super::Interface for Balance {
replacement in beancount/types/src/directive/balance.rs at line 84
[2.79492]→[2.79492:79531](∅→∅) − pub const fn date(&self) -> Date {
+ fn date(&self) -> Date {
replacement in beancount/types/src/directive/balance.rs at line 90
[2.79586]→[2.79586:79635](∅→∅) − pub fn main_account(&self) -> Option<&Acc> {
+ fn main_account(&self) -> Option<&Acc> {
replacement in beancount/types/src/directive/balance.rs at line 96
[3.13224]→[3.1235:1291](∅→∅),
[3.1235]→[3.1235:1291](∅→∅) − pub fn timestamp(&self) -> Option<OffsetDateTime> {
+ fn timestamp(&self) -> Option<OffsetDateTime> {
edit in beancount/types/src/directive/balance.rs at line 121
+
+ impl super::seal::Sealed for Balance {}
edit in beancount/types/Cargo.toml at line 10
+ # Inherited dependencies
+ arrayvec.workspace = true
+ delegate.workspace = true
+ enum-kinds.workspace = true
+ enum_dispatch.workspace = true
+ lazy-regex.workspace = true
+ miette.workspace = true
+ momo.workspace = true
+ once_cell.workspace = true
+ regex.workspace = true
+ rust_decimal.workspace = true
+ serde.workspace = true
+ snafu.workspace = true
+ tap.workspace = true
+ time.workspace = true
+ time-tz.workspace = true
edit in beancount/types/Cargo.toml at line 35
[3.25977]→[3.226:251](∅→∅),
[3.251]→[3.14857:14917](∅→∅),
[3.14917]→[3.454:484](∅→∅),
[3.484]→[3.14917:15067](∅→∅),
[3.14917]→[3.14917:15067](∅→∅),
[3.15067]→[3.381:411](∅→∅),
[3.381]→[3.381:411](∅→∅),
[3.411]→[3.15068:15158](∅→∅),
[3.15188]→[3.15188:15218](∅→∅),
[3.15218]→[3.237:267](∅→∅) − # Inherited dependencies
− arrayvec.workspace = true
− delegate.workspace = true
− enum-kinds.workspace = true
− lazy-regex.workspace = true
− miette.workspace = true
− momo.workspace = true
− once_cell.workspace = true
− regex.workspace = true
− rust_decimal.workspace = true
− serde.workspace = true
− snafu.workspace = true
− tap.workspace = true
− time.workspace = true
− time-tz.workspace = true
resolve order conflict in beancount/types/Cargo.toml at line 35
edit in beancount/tree-writer/src/lib.rs at line 19
+ use beancount_types::DirectiveInterface as _;
edit in Cargo.toml at line 36
+ enum_dispatch = "0.3.13"
edit in Cargo.lock at line 479
edit in Cargo.lock at line 1113
+ ]
+
+ [[package]]
+ name = "enum_dispatch"
+ version = "0.3.13"
+ source = "registry+https://github.com/rust-lang/crates.io-index"
+ checksum = "aa18ce2bc66555b3218614519ac839ddb759a7d6720732f979ef8d13be147ecd"
+ dependencies = [
+ "once_cell",
+ "proc-macro2",
+ "quote",
+ "syn 2.0.58",