我有一个特征,我想在其上有一个关联的常量,其中常量将是实现该特征的类型的片段。`...
note: ...so that the reference type `&'static [Self]` does not outlive the data it points at 相关常量的生命周期界限是如何表示的如果相关,我使用的是最新的rustc稳定版(1.42.0)和2018版。
我正在开发一个多项式的实现,它在整数系数的情况下使用了一个C库。但是,当系数来自其他环时,我想定义一个不同的实现。当我们使用C库时,我们需要处理一些底层的值,我们将这些值传递给C,并分组到一个结构中。否则,不需要定义这些值。我如何实现这一点?c_value: StructDependingOnT, // only needs to be defined when T is an integer for example
} 我的想法是有一个特征来指定何
基类(通常是抽象的基类)可以有一些方法,这些方法可以通过覆盖子类中的常量进行调整。这些常量也可以有默认值。My name is Stephen HawkingPHP Fatal error: Traits cannot have constants in/mnt/tmpfs/1.php on line 4
那么在特征中使用它们是可能的吗?