Keyword identifier collisions, eg `type`


What do people do when they have a keyword collision? Eg, I have a struct that I’d like to give a type field:

pub enum Type {

pub struct PowerSupply {
    type: Type,

I can do a syntactic change like type_, or I can add more words like power_supply_type. The first is ugly, the second verbose and redundant. What do people do in this sort of situation?


Sometimes a synonym is ok – perhaps kind instead of type.


Rustc often abbreviates ‘type’ to ‘ty’.


Or suffix it with an underscore, as in:

pub struct PowerSupply {
    type_: Type,


ty for type and krate for crate.

The problem with this is that kind is already a term of art when talking about types…


But what do I do if i need this for FFI? How do I call a C function void type(void)?

extern {
    #[link_name = "type"]
    fn type_();