Introduce negative import bounds for glob imports

Hello, everyone

I have an idea to we introduce negative bounds only appear in glob imports example usage:

use std::marker::*!{Unpin};

This mean import me everything from std::marker excluding Unpin, This will be very useful in some situations.

Hmm... can you suggest a usecase for this? I'm not sure where it would be useful.

2 Likes

The usecase of this especially in exports by example you export everything to the crate except myprivfn and PrivateStruct.

pub use crate::mymod::*!{myprivfn, PrivateStruct};

I see. In that case, I don't think there would be that much of a problem in changing it (but I am not knowledgeable in these parts of the compiler) This does seem useful.

Using a denylist like that to define a public API seems error-prone, since it'd be easy to add a new private item and not exclude it. An allowlist seems safer for that purpose.

10 Likes

or instead to make it more safer more safer

pub use crate::mymod::pub *;

Or similar

that export everything in to the crate root that is public.

1 Like

Standard response: you're discussing a feature without elaborating on the motivation. The motivation is more important than any specific feature.

What are you trying to do? Avoid name conflicts? Define your crate's API? ...

8 Likes