首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >何时应将“静态绑定”添加到特性定义中

何时应将“静态绑定”添加到特性定义中
EN

Stack Overflow用户
提问于 2021-06-03 01:51:08
回答 1查看 86关注 0票数 1

有人能为我解释一下'static的用法吗?我看到了这段代码,但我不明白它是如何使用的。

代码语言:javascript
复制
// 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>;
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-06-03 02:06:29

作为一个特征绑定,它意味着类型不包含任何非静态引用。例如:接收者可以在他们想要的时间内保留类型,直到他们放弃它,它才会变得无效。

请参阅:静态-锈蚀的例子

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67814450

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档