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

Update reexports in module vulkano::instance #390

Merged
merged 1 commit into from
Feb 27, 2017

Conversation

DaseinPhaos
Copy link
Contributor

@DaseinPhaos DaseinPhaos commented Feb 27, 2017

This PR reexports vulkano::instance::layers::LayersListError to make it public-visible.

This is necessary because a former reexport pub use self::layers::layers_list introduces Result<LayersIterator, LayersListError> into the public interface. This in essence actually introduces a private type into the public interface.
Most of the times there would be no problem using values of this smuggled-out type. pub-implemented methods and trait methods can be invoked by outer code just as if the type is actually public visible. However, when the path to this type needs to be explicitly specified, like in the case when a consumer wants to chain this error type with error-chain, the compiler would complain that the type is not in scope. AFAIK the only way to to solve this is via another reexport, making this type really public-visible.


A quick example explaining what's going on there:

mod visible {
    pub use self::invisible::bomb_here;

    mod invisible {
        #[derive(Copy, Clone)]
        pub struct Oops { inner: i32 }

        impl Oops {
            pub fn inner(&self) -> i32 { self.inner }
        }

        pub fn bomb_here() -> Oops { Oops { inner : 1 } }
    }
}

fn main() {
    // This is OK:
    let oops = visible::bomb_here(); 

    // `Copy` is OK:
    let ooops = oops;

    // Method invocation is OK:
    let invisible = oops.inner(); 

    // BOOM! This won't compile. Explicitly specifying
    // the type name blows the compiler up:
    let boom: visible::invisible::Oops = oops;
                                     
}

This PR reexport `vulkano::instance::layers::LayersListError` such that it becomes public visible.
This is necessary because another reexport in that module, `pub use self::layers::layers_list` makes `Result<LayersIterator, LayersListError>` public visible. Due to the visibility philosophy we should make its wrapped types public visible too.
@tomaka
Copy link
Member

tomaka commented Feb 27, 2017

Thanks

@tomaka tomaka merged commit 19eed62 into vulkano-rs:master Feb 27, 2017
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

Successfully merging this pull request may close these issues.

None yet

2 participants