What is a type in the header

HI there, I'm new to the programming world and begin with rust. I've wondered what is a type as in '' bringing a type called std::cmp::Ordering into scope".
What does a type mean in this context? What is the relationship betwen cmp and ordering?

In this case, Ordering is the name of the type, cmp is the name of the module containing the Ordering type and std::cmp::Ordering is the path to the type Ordering.


Every variable, and more generally every value, has a type. In addition to the built in types, Rust programs and libraries can define their own types. You can use a few of these without declaring that you're going to use them, for example Option and Vec. But usually you have to bring it in to scope or type out the full path to the type.

More generally, from the book,

And std::cmp::Ordering in particular is an enum, and you can see its definition here. From that definition, every value that has the type Ordering is equal to one of:

  • Ordering::Less
  • Ordering::Equal
  • Ordering::Greater