Skip to content

Remove the need for the “Remaining generic in your crate” paragraph in the README? #12

@Ekleog

Description

@Ekleog

Random drive-by thought: if external_library generated code like this when not having the dlopen feature:

mod private {
    #[link(name = "foo")]
    extern "C" {
        static me: c_int;
        static you: c_float;
        fn foo() -> c_int;
        fn bar(_: c_int, _: c_float) -> ();
        fn baz(_: *const c_int) -> c_int;
        fn blah(_: c_int, _: c_int, ...) -> *const c_void;
        fn bleh(_: c_int, ...) -> ();
   }

   pub struct Foo {
       pub me: &'static c_int,
       pub you: &'static c_float,
       pub foo: unsafe extern "C" fn() -> c_int,
       pub bar: unsafe extern "C" fn(c_int, c_float) -> (),
       pub baz: unsafe extern "C" fn(*const c_int) -> c_int,
       pub blah: unsafe extern "C" fn(c_int, c_int, ...) -> *const c_void,
       pub bleh: unsafe extern "C" fn(c_int, ...) -> (),
    }

    impl Foo {
        pub fn open(_: Option<&str>) -> Result<Foo, DlError> { /* ... */ }
    }
}
use private::Foo;

Then the user could just always use Foo::open(find_solib_or_none("foo.so")).foo(), without having to care about the dlopen feature?

It'd probably also reduce a bit the issue with the dlopen feature, which is that currently it's not additive.

That said it would still not really be, but if Foo::open(None) with the dlopen feature searched in the so path… then maybe it'd actually become kind of additive? (still not perfectly so, but at least for all reasonable users that either pass a valid Some(lib) or None it'd be)

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