D 的 `std.sumtype` 在哪里?

Where is D's `std.sumtype`?

我正在用 D 语言开发一个项目,我想使用标准库中的一个模块 std.sumtype。我在 debian oldstable 上,我已经尝试过 GDC 和 LDC。 DMD 不可用,因为我使用的是 armhf 架构的机器。这些编译器都找不到 std.sumtype,尽管它在标准库中。我还尝试从所有三个 D 编译器的 phobos 存储库下载 3 个不同版本的 sumtype.d。这些中的每一个都不会编译。我该如何使用它?我是不是用错版本了?

std.sumtype 是在 2.097.0 中添加的一个非常新的软件包:https://dlang.org/changelog/2.097.0.html#std-sumtype 所以 debian oldstable 软件包可能还没有它,因为您至少需要它:

  • DMD 2.097.0
  • LDC 1.27.0(beta.1 或更高版本)
  • 即将于 2022 年 5 月举行的 GDC(请参阅 announcement

如果您想使用最新的编译器,您可以随时下载最新的 LDC archive and extract it somewhere and run it from there or use the install.sh script from the download page 以进行便携和多个同时安装。

std.sumtype 是对 dub 包的采用 sumtype 所以如果你正在使用 dub,你也可以依赖它而不需要在包管理器之外获取另一个编译器。