Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow constructing structs through associated fields #17

Open
arielb1 opened this issue Aug 10, 2017 · 0 comments
Open

Allow constructing structs through associated fields #17

arielb1 opened this issue Aug 10, 2017 · 0 comments

Comments

@arielb1
Copy link

arielb1 commented Aug 10, 2017

This would be useful for rust-lang/rfcs#2102:

#[repr(C)]
pub union _Bindgen_somestruct_Field_0 {
    pad_binder: binder_uintptr_t,
    fd: u32
}

#[repr(C)]
pub union _Bindgen_somestruct_Field_target {
    handle: u32,
    ptr: binder_uintptr_t,
}

#[repr(C)]
pub struct somestruct {
    _Field_0: _Bindgen_somestruct_Field_0,
    target: _Bindgen_somestruct_Field_target
};

impl somestruct {
    unsafe pad_binder: self._Field_0.pad_binder;
    unsafe fd: self._Field_0.fd;
}

fn foo() {
    let somestruct = unsafe { somestruct {
        fd: 2,
        target
    }};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant