如在此存储库中所见:
https://github.com/ReactiveX/RxRust/blob/master/src/lib.rs#L110
let gen = move |:| {
let it = range(0is, 20is);
// ~~~ ~~~~
let q = Box::new(Decoupler::new(dtx.clone()));
let mut map1 = Box::new(Map::new(|i : isize| {i * 10}));
let mut map2 = Box::new(Map::new(|i : isize| {i + 2}));
let mut iter = Box::new(IterPublisher::new(it));
map2.subscribe(q);
map1.subscribe(map2);
iter.subscribe(map1);
};
(用波浪线强调我的)
我想弄清楚数字后面的 是
是什么。本书仅简要介绍了文字后缀:
Note that all number literals except the byte literal allow a type suffix, such as 57u8, and _ as a visual separator, such as 1_000.
— https://doc.rust-lang.org/book/ch03-02-data-types.html#integer-types
而且编译器 (1.53) 只能理解一组特定的后缀,所以我什至无法在我的机器上构建原始 crate:
invalid suffix `is`
help: the suffix must be one of the numeric types (`u32`, `isize`, `f32`, etc.)
这是某种古老的语法,还是我遗漏了什么?
最佳答案
在旧的 1.0 之前的时代,整数后缀有点不同。
感谢 Wayback Machine ,我们可以回顾一下过去:
There are 10 valid values for an integer suffix: \
- The
is
andus
suffixes give the literal typeisize
orusize
, respectively.- Each of the signed and unsigned machine types
u8
,i8
,u16
,i16
,u32
,i32
,u64
andi64
give the literal the corresponding machine type.
但在 Rust 1.0 中,第一个项目符号消失了,现在您编写 20isize
而不是 20is
。
关于rust - Rust 中的 "0is"表示法是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68767869/