Module with builtin types

Is there an stdlib module with build in types, like the one in go? I’d love to use it to provide goto definition/quick documentation for builtins. I’ve only found primitive_docs.rs, but it won’t work that easily because the names of primitives are different.

I wish it were

#[allow_bultin_shadowing]
type bool = bool;

rather then

#[doc(primitive = "bool")]
mod prim_bool { }

:slight_smile:

Just a curiosity, in 1.10 error for type bool = bool is E0391, cyclic references, in 1.9 it was E0317, builtin shadowing.

You may be interested in this PR which did very similar thing (but more ambitious), but was decided against after all.

As for type bool = bool;, there’s a simple workaround

mod detail {
    pub type __bool = bool;
}

type bool = detail::__bool;

, so a module with primitive types can be added to the standard library. It would be useful in situation where a primitive type needs to be addressed by an absolute name, like here.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.