gpt4 book ai didi

rust - 在 Rust 中运行时初始化的全局常量?

转载 作者:行者123 更新时间:2023-11-29 08:16:26 27 4
gpt4 key购买 nike

<分区>

是否可以定义一个全局常量,其值在运行时开始计算?有点像

static START_TIME: time::Timespec = time::get_time();

如果可能的话。 staticconst 声明需要编译时值(常量调用仅限于 struct 和 enum 构造函数)并且 let 不能放在函数外部(错误:预期项目,找到 `let`)。

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com