Rust 中默认的整数类型是什么? [英] What is the default integer type in Rust?
本文介绍了Rust 中默认的整数类型是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在执行以下操作时:
let mut sum = 5 + 10;
sum
的确切类型是什么?是不能溢出的任意大小的类型吗?
What is the exact type of sum
? Is it an arbitrary-size type which can’t be overflowed?
推荐答案
有 RFC 212,其中指出:
类型不受约束的整数文字将默认为 i32
Integer literals whose type is unconstrained will default to
i32
如果你想要一个简单的 lint default_numeric_fallback代码>
,它可以警告您不需要的回退.
If you want there is a clippy lint default_numeric_fallback
that can warn you about unwanted fallback.
这篇关于Rust 中默认的整数类型是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文