-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Description
I'd like to use a type alias, in this case c_int
, as the repr
of an enum. For example, in this code snippet:-
extern crate libc;
use self::libc::c_int;
#[repr(c_int)]
pub enum Facility
{
LOG_KERN = self::libc::LOG_KERN,
// ... Omitted ...
}
(Note, LOG_KERN
is not yet defined in libc
, but I'm working on a PR for it). The type alias for LOG_KERN
is c_int
, which resolves to i32
on Mac OS X.
Whilst I can use a repr
of i32
, I'd rather not. Whilst in this particular case it's very highly unlikely that the definition of c_int
will every change or vary across platforms (16-bit rust, anyone), one loses expressiveness and introduces a little more need to understand what's going on - limiting the usefulness of a type alias...
I've raised this as an issue, not a RFC or anything like that (a) because I'm new to all of this and (b) because what I just did was what I thought would be logical - it's the very first time I tried to use repr, and it didn't work as seemed obvious. Obviously if there's a better forum I'll move this.
Activity
steveklabnik commentedon May 5, 2016
Welcome!
So, in general, question-type things are best posted to https://users.rust-lang.org/ or http://internals.rust-lang.org/ , I would say this leans more internals. We try to keep the bug tracker for bugs only.
However, as it just so happens, an RFC was opened a few days ago for this exact issue, so I'd suggest you get involved over there!
Thanks :)
raphaelcohn commentedon May 5, 2016
Thank you. I'll get on to the RFC...