【rust编译错误解读】

PANIC

1cannot index into a value of type std::option::Option<&Vec<Value>>

(不能访问下标index在一个Option包裹的Vec中)

尝试对一个 Option 类型的值进行索引操作,而这个 Option 可能包含一个对 Vec 的引用,或者它可能是 None。在 Rust 中,你不能直接对 Option 类型的值进行索引,因为它不是序列类型(像 Vec 或数组那样)。你需要先从 Option 中提取出 Vec 的引用,然后才能对它进行索引。

2 mismatched types
expected struct Vec<(f64, f64)>
found struct std::iter::Map<std::option::Iter<'_, &Vec<Value>>, {closure@src\main.rs:242:62: 242:67}>

3 mismatched types
expected struct dashmap::mapref::multiple::RefMulti<'_, std::string::String, data>
found tuple (_, _)rustcClick for full compiler diagnostic
main.rs(263, 28): this is an iterator with items of type dashmap::mapref::multiple::RefMulti<'_, std::string::String, data>

derive may only be applied to structs, enums and unions

错误信息 "derive may only be applied to structs, enums and unions" 表明你尝试在一个不是结构体(struct)、枚举(enum)或联合(union)的项上使用 derive 属性宏。在 Rust 中,derive 属性用于自动派生一些特性(traits)的实现,如 Debug、PartialEq 等,但它只能用于特定的类型。

WARN

variable BTC_subscription should have a snake case name
#[warn(non_snake_case)] on by defaultrustcClick for full compiler diagnostic
main.rs(103, 10): convert the identifier to snake case: btc_subscription

在 Rust 中,有一个编码规范建议变量名应该使用蛇形命名法(snake_case)。这意味着变量名应该全部由小写字母组成,单词之间使用下划线(_)分隔。这个规范在 Rust 的默认设置 #[warn(non_snake_case)] 中是开启的,所以如果你的变量名不符合这个规范,编译器会发出警告。

根据你提供的错误信息,你需要将变量名 BTC_subscription 转换为蛇形命名法。你可以将其重命名为 btc_subscription

相关推荐
echome8886 分钟前
JavaScript Promise 与 async/await 实战:5 个高频异步编程场景的优雅解决方案
开发语言·javascript·ecmascript
xcLeigh28 分钟前
IoTDB Java 原生 API 实战:SessionPool 从入门到精通
java·开发语言·数据库·api·iotdb·sessionpool
杜子不疼.29 分钟前
Java 智能体学习避坑指南:3 个常见误区,新手千万别踩,高效少走弯路
java·开发语言·人工智能·学习
冬天vs不冷29 分钟前
为什么 Java 不让 Lambda 和匿名内部类修改外部变量?final 与等效 final 的真正意义
android·java·开发语言
星河耀银海30 分钟前
JAVA 多线程编程:从基础原理到实战应用
java·开发语言·php
星河耀银海30 分钟前
JAVA IO流:从基础原理到实战应用
java·服务器·开发语言
摸鱼仙人~1 小时前
Math.js 使用教程
开发语言·javascript·ecmascript
HAPPY酷1 小时前
Python高阶开发:从底层原理到架构设计的进阶之路
开发语言·python
sxhcwgcy2 小时前
SpringBoot 使用 spring.profiles.active 来区分不同环境配置
spring boot·后端·spring
疯狂打码的少年2 小时前
【Day 6 Java转Python】字符串处理的“降维打击”
java·开发语言·python