如何解决在当前作用域中未找到针对struct`chrono :: offset :: utc :: Utc`的名为`now`的函数或相关项
这是我要在其中使用的代码:
use chrono::{DateTime,Utc};
struct Attributes {
time: Option<DateTime<Utc>>,}
impl Default for Attributes {
fn default() -> Self {
Attributes {
time: Some(chrono::offset::Utc::Now()),}
}
}
这是我在运行货物时遇到的错误:
error[E0599]: no function or associated item named `Now` found for struct `chrono::offset::utc::Utc` in the current scope
--> src/event/v03/attributes.rs:165:45
|
165 | time: Some(chrono::offset::Utc::Now()),| ^^^ function or associated item not found in `chrono::offset::utc::Utc`
我不确定问题出在哪里,但我确定该方法存在。任何见识将不胜感激。
解决方法
这对我来说是一个很愚蠢的错误。我忽略了在关闭chrono
功能的情况下使用std
的事实。这要求我禁用所有其他默认功能,包括方便clock
的功能chrono::offset::Utc::now()
。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。