有人能为我解释一下'static的用法吗?我看到了这段代码,但我不明白它是如何使用的。
// When should 'static bound' be added to trait definitions
pub trait FinalitySyncPipeline: 'static + Clone + Debug + Send + Sync {
/// Name of the finality proofs source.
const SOURCE_NAME: &'static str;
/// Name of the finality proofs target.
const TARGET_NAME: &'static str;
/// Headers we're syncing are identified by this hash.
type Hash: Eq + Clone + Copy + Send + Sync + Debug;
/// Headers we're syncing are identified by this number.
type Number: relay_utils::BlockNumberBase;
/// Type of header that we're syncing.
type Header: SourceHeader<Self::Number>;
/// Finality proof type.
type FinalityProof: FinalityProof<Self::Number>;
}发布于 2021-06-03 02:06:29
作为一个特征绑定,它意味着类型不包含任何非静态引用。例如:接收者可以在他们想要的时间内保留类型,直到他们放弃它,它才会变得无效。
请参阅:静态-锈蚀的例子
https://stackoverflow.com/questions/67814450
复制相似问题