News for hackers. Stuff that matters.
Re:Rust's 2019 Roadmap by v_lisivka on Tuesday April 23, 2019 @04:29PM (#19732504)
One long-standing problem is the incompatibility of Rust enum with C enum. In C, enum's are just labels for integers, similar to const int values in Rust, so C enum { A=0, B=1, C=2 } is more like Rust's enum E { A=0, B=1, C=2, Unlabeled(3..MAX_INT32), } . This slight incompatibility forces writing of converters between C enums and Rust enums.

See https://github.com/rust-lang/rust-bindgen/issues/667

Re:Rust's 2019 Roadmap by v_lisivka on Wednesday April 24, 2019 @04:48AM (#19736621)
Can anybody explain the downvotes? It looks suspicious.

It's well known and long standing problem. Rust the Language allows proper enum, but Rust the Compiler cannot pack enum into single value, as in C.

Example:

  #[repr(C)]
  #[repr(i32)]
  #[derive(Debug)]
  #[allow(dead_code)]
  enum E {
    A,
    B,
    C,
    Unlabeled(i32),
  }

  fn main() {
    {
        let v: E = unsafe { std::mem::transmute::<(i32,i32), E>((0,0)) };
        println!("v = {:?}", v)
    }
    {
        let v: E = unsafe { std::mem::transmute::<(i32,i32), E>((1,1)) };
        println!("v = {:?}", v)
    }
    {
        let v: E = unsafe { std::mem::transmute::<(i32,i32), E>((2,2)) };
        println!("v = {:?}", v)
    }
    {
        let v: E = unsafe { std::mem::transmute::<(i32,i32), E>((3,3)) };
        println!("v = {:?}", v)
    }
    {
        let v: E = unsafe { std::mem::transmute::<(i32,i32), E>((3,55)) };
        println!("v = {:?}", v)
    }
    {
        let v: E = unsafe { std::mem::transmute::<(i32,i32), E>((55,55)) };
        println!("v = {:?}", v)
    }
  }

Output:

  v = A
  v = B
  v = C
  v = Unlabeled(3)
  v = Unlabeled(55)
  v = A
Re:Rust's 2019 Roadmap by pleasecalllater on Sunday April 28, 2019 @03:31AM (#19769868)
> Can anybody explain the downvotes? It looks suspicious.

I can. This is a long tradition here. If someone criticizes something loved by people with little knowledge (aka fangirls and fanboys) then they downvote it.

The truth doesn't matter, the hurt feelings do. And it's downvoted without any explanation.

I had this many times, I'm thinking about not posting at all. It's not worth it. There is no discussion, just downvotes.

I'm sure this will be downvoted too :)