In the swagger-codegen for the rust client, there is an odd reference that I cannot find elsewhere. It looks like a baseless type reference, but I am not sure.
What is the ::apis::... ? I thought all of these references needed to be based on some object or type?
What is this a trait of? ???::apis::...
Why put two colons before apis though? Typically, the crate is supposed to come before the ::, no? Does it just mean, 'look in this local file for this type'?
If you put crate out from, crate::apis then you are saying look for a top-level module named apis, not a dependency named apis. It's an old syntax, now you can just say apis:: without the leading ::
// I have a dependency named apis as well
mod apis;
// which does this refer to? the module,
// but we wanted it to refer to the dependency
use apis::???;
// this is the correct way to refer to the dependency
use ::apis::???;
It looks like it's trying to prevent this sort of ambiguity, or is trying to be backwards compatible.
It's kinda like the module version of Universal Function Call Syntax. Like how you might write <SomeType as std::io::Write>::write(&mut some_writer) when both std::io::Write and std::fmt::Write are in scope (they both have a write() method).
You'll often see it used it in macros or generated code, because you don't necessarily know what the caller will have in scope at the time and want to avoid ambiguities.