eclipse-zenoh / zenoh

zenoh unifies data in motion, data in-use, data at rest and computations. It carefully blends traditional pub/sub with geo-distributed storages, queries and computations, while retaining a level of time and space efficiency that is well beyond any of the mainstream stacks.
https://zenoh.io
Other
1.44k stars 151 forks source link

Remove some duplicate imports #1160

Closed evshary closed 3 months ago

evshary commented 3 months ago

Now there are some duplicate imports in lib.rs

use zenoh::{Error, Result};
use zenoh::core::{Error, Result};

use zenoh::{Session, open};
use zenoh::session::{Session, open};

use zenoh::scout;
use zenoh::scouting::scout;

For session one, it's used commonly and perhaps it makes sense to have a shorter path. However, I would suggest not to have duplicate paths for others.

Mallets commented 3 months ago

I'm not sure about this change... @milyin ?

wyfo commented 3 months ago

@Mallets you should have tagged me also 🙂

@evshary Reexporting in root is a common practice across Rust ecosystem; you never use serde::ser::Serialize but serde::Serialize. Having root reexport of Result overload (and custom Error) is also quite a convention, see serde_json::Result/serde_json::Error.

You may be interested in #1007 where the discussion about root reexporting took place.

evshary commented 3 months ago

@wyfo You convince me now why putting these under the root. Then, the question might be why we choose these to re-export. Is there any rule for this?

wyfo commented 3 months ago

There is no "rule" as far as I know. Some crates like rand choose to not reexport, others like serde_json do it. So you can find both in fundamental crates of the ecosystem.

IMO, it is a matter of taste. When I wrote the reexports, I had serde_json way of doing in mind. This is obviously a debatable decision, and we solve and close that debate quickly before 1.0.

That's also something we could ask on Reddit like folks of ratatui did. Thanks to those Reddit/Rust forum discussion, we already closed the prelude discussion by keeping only traits in it. I think I will open a Reddit discussion on Monday.

Mallets commented 3 months ago

Superseded by https://github.com/eclipse-zenoh/zenoh/pull/1193