Skip to content

Using Box instead of platform specific RawSymbol #1

@wrenger

Description

@wrenger

Very good article.

However it seems to me a little bit odd using the platform specific RawSymbol in the VTableV0 implementation to get around the lifetime checks.
Maybe a better cross platform approach could be dereferencing the Symbol and storing the function pointer as std::boxed::Box.

struct VTableV0 {
     free_object: Box<FreeObject>,
     get_info: Box<GetInfo>,
     set_info: Box<SetInfo>,
}

// ...

let free_object: Symbol<FreeObject> = library.get(b"free_object\0").unwrap();
let free_object = Box::new(*free_object);

Apart from that i like your article very much, thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions