Rust中的“0is”符号是什么?

正如在这个存储库中看到的:

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);
};

(弯弯曲曲地强调我的)

我想弄清楚数字is后面是什么。这本书仅简要介绍了字面后缀:

请注意,除字节字面量之外的所有数字字面量都允许类型后缀,例如 57u8,以及 _ 作为视觉分隔符,例如 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,我们可以回顾过去:

整数后缀有 10 个有效值:

  • isus后缀得到文本类型isizeusize分别。
  • 每个有符号和无符号机器类型u8, i8, u16, i16, u32, i32,u64i64为文字提供相应的机器类型。

但是在 Rust 1.0 中,第一个子弹消失了,现在你写的20isize20is.


以上是Rust中的“0is”符号是什么?的全部内容。
THE END
分享
二维码
< <上一篇
下一篇>>