Rust 中的“0is”符号是什么?
What is "0is" notation in Rust?
如此存储库中所示:
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
是什么。该书仅简要介绍了文字后缀:
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
and us
suffixes give the literal type isize
or usize
, respectively.
- Each of the signed and unsigned machine types
u8
, i8
, u16
, i16
, u32
, i32
, u64
and i64
give the literal the corresponding machine type.
但是在 Rust 1.0 中,第一颗子弹消失了,现在你写 20isize
而不是 20is
。
如此存储库中所示:
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
是什么。该书仅简要介绍了文字后缀:
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
。