当前位置:网站首页>How to specify const array in the global scope of rust- How to specify const array in global scope in Rust?
How to specify const array in the global scope of rust- How to specify const array in global scope in Rust?
2022-07-03 00:04:00 【Technology feast】
problem :
When I tried to add a const array in the global scope using this code: When I try to add one globally using the following code const Array time :
static NUMBERS: [i32] = [1, 2, 3, 4, 5];I got the following error: I received the following error :
error: mismatched types: expected `[i32]`, found `[i32; 5]`(expected slice, found array of 5 elements) [E0308]static NUMBERS2: [i32] = [1, 2, 3, 4, 5]; ^~~~~~~~~~~~~~~The only way I found to deal with this problem is to specify the length in the type: I found that the only way to deal with this problem is to specify the length in the type :
static NUMBERS: [i32; 5] = [1, 2, 3, 4, 5];Is there a better way? Is there a better way ?It should be possible to create an array without manually counting its elements. It should be possible to create an array without manually calculating its elements .
Solution :
Reference resources : https://stackoom.com/en/question/1bu4m边栏推荐
- I've been interviewed. The starting salary is 16K
- Installing redis under Linux
- QT 如何将数据导出成PDF文件(QPdfWriter 使用指南)
- Interface difference test - diffy tool
- Speech recognition Series 1: speech recognition overview
- Integration of revolution and batch normalization
- leetcode 650. 2 keys keyboard with only two keys (medium)
- Top Devops tool chain inventory
- 来自数砖大佬的 130页 PPT 深入介绍 Apache Spark 3.2 & 3.3 新功能
- JDBC Exercise case
猜你喜欢

Convolution和Batch normalization的融合

List of major chip Enterprises

Detailed explanation of 'viewpager' in compose | developer said · dtalk

基于OpenCV实现口罩识别

Difference between NVIDIA n card and amda card

程序分析与优化 - 9 附录 XLA的缓冲区指派

Implementation of VGA protocol based on FPGA

How to set automatic reply for mailbox and enterprise mailbox?

实用系列丨免费可商用视频素材库

直击产业落地!飞桨重磅推出业界首个模型选型工具
随机推荐
Practical series - free commercial video material library
接口差异测试——Diffy工具
Is the multitasking loss in pytoch added up or backward separately?
Open Source | Wenxin Big Model Ernie Tiny Lightweight Technology, Accurate and Fast, full Open Effect
Top Devops tool chain inventory
ArrayList分析2 :Itr、ListIterator以及SubList中的坑
一文掌握基于深度学习的人脸表情识别开发(基于PaddlePaddle)
Sourcetree details
Pytorch里面多任务Loss是加起来还是分别backward?
[error record] the flutter reports an error (could not resolve io.flutter:flutter_embedding_debug:1.0.0.)
Interface switching based on pyqt5 toolbar button -2
Hit the industry directly! The propeller launched the industry's first model selection tool
Data set - fault diagnosis: various data and data description of bearings of Western Reserve University
Analyze ad654: Marketing Analytics
【ML】李宏毅三:梯度下降&分类(高斯分布)
程序分析与优化 - 9 附录 XLA的缓冲区指派
Writing of head and bottom components of non routing components
[shutter] shutter photo wall (center component | wrap component | clickrrect component | stack component | positioned component | button combination component)
数据集-故障诊断:西储大学轴承的各项数据以及数据说明
Third party payment function test point [Hangzhou multi tester _ Wang Sir] [Hangzhou multi tester]