Hacker News new | ask | show | jobs
by leshow 2874 days 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.

1 comments

const and mut are not types, it's modifiers of mutability. On both lines type is u32z
The 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.
I 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.
leshow 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.
The asterisk was formatted out. Read the book, they are types.
So you can write "let x:const = 5"? if "const" is a type.
You 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?