6 ms·
A pointer is absolutely a type in rust. let i: u32 = 1; let p_imm: const u32 = &i; Look at the const u32 in the type position. The rust book even refers to
by leshow 8y ago
A pointer is absolutely a type in rust.
let i: u32 = 1;
let p_imm: const u32 = &i;
Look at the const u32 in the type position.
The rust book even refers to const and mut pointers as types.
- EugeneOZ 8y agoconst and mut are not types, it's modifiers of mutability. On both lines type is u32z
- foldr 8y agoThe asterisks in leshow's comment are being lost in the formatting, since HN uses them for italicization. So the last line, for example, is: The rust book even refers to *const and *mut pointers as types.
- EugeneOZ 8y agoI really can't believe how stupid people can be to say "const" is a type. Even if Klabnik will say it into my face it will not be true, I don't care about the book he wrote.
- foldr 8y agoleshow said that *const u32 is a type, not that 'const' is a type. HN's formatting removed the asterisk, as it uses asterkisks for italicization.
- leshow 8y agoThe asterisk was formatted out. Read the book, they are types.
- EugeneOZ 8y agoSo you can write "let x:const = 5"? if "const" is a type.
- leshow 8y agoYou were just told the formatting removed the asterisk. const isn't a type, but a const pointer is, so is a mut pointer. It says so in the book AND it's in the position of a type in the code. What other information do you need to convince you that you're wrong?