You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
They currently have very different semantics: the former is a lock-protected container while the latter is only a lock. I just spent a few minutes very confused, looking at the docs for one of them to understand code using the other.
Combined with #15723 and libstd-as-a-facade (many items with the same name documented in different modules are in fact the same item), this really brings down the doc’s usability.
sync::Mutex vs sync::mutex::Mutex is just the example I hit today, but same-name-but-different items is a pattern we should avoid in general.
I think using the same name for both is fine as long as the paths leading up to it make it clear that one is a low-level mutex for unsafe code and the other is a high-level abstraction.
@thestinger, sync::Mutex vs sync::mutex::Mutex does not convey this at all, IMO. Worse, it is relatively common to reexport at the crate top-level things that are defined in modules: exactly the same naming pattern with a very different meaning.
Activity
thestinger commentedon Sep 16, 2014
I think using the same name for both is fine as long as the paths leading up to it make it clear that one is a low-level mutex for
unsafe
code and the other is a high-level abstraction.SimonSapin commentedon Sep 16, 2014
@thestinger,
sync::Mutex
vssync::mutex::Mutex
does not convey this at all, IMO. Worse, it is relatively common to reexport at the crate top-level things that are defined in modules: exactly the same naming pattern with a very different meaning.thestinger commentedon Sep 16, 2014
I realize that, I'm saying that it would be fine if the paths were better.
SimonSapin commentedon Sep 16, 2014
I was gonna suggest that
sync::mutex
could move tosync::raw::mutex
, but I just found out thatsync::raw::Mutex
is yet another different type…huonw commentedon Sep 16, 2014
#14530
aturon commentedon Jan 17, 2015
This issue is no longer relevant after the
sync
overhaul.