А enum по дефолту идет isize - можно ли изменить

поведение, чтоб оно например было u8 ?

4 ответов

14 просмотров

[repr(u8)]

Откуда про isize взял инфу?

Dima-Ficus Автор вопроса
Lya
Откуда про isize взял инфу?

``` enum Ex { One = 1u8, Two, } ``` будет ругаться что он ожидает isize

Lya
Откуда про isize взял инфу?

https://doc.rust-lang.org/reference/items/enumerations.html Under the default representation, the specified discriminant is interpreted as an isize value although the compiler is allowed to use a smaller type in the actual memory layout

Похожие вопросы

Обсуждают сегодня

Карта сайта