PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, December 22, 2022

[FIXED] What is "0is" notation in Rust?

 December 22, 2022     rust, rust-obsolete, syntax     No comments   

Issue

As seen in this repository:

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

(squiggly emphasis mine)

I'm trying to figure out what is after a numeral is. The Book says about literal suffixes only briefly:

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

And the compiler (1.53) only understands a set of specific suffixes, so I could not even get the original crate built on my machine:

invalid suffix `is`
help: the suffix must be one of the numeric types (`u32`, `isize`, `f32`, etc.)

Is it some sort of archaic syntax, or is it me missing something?


Solution

In the old, pre 1.0, times, integer suffixes were a little different.

Thanks to the Wayback Machine, we can take a peek to the past:

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.

But in Rust 1.0 the first bullet went away and now you write 20isize instead of 20is.



Answered By - rodrigo
Answer Checked By - David Goodson (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing