What is the "named tuple" in Rust By Example?

Question: Question:

I'm new to Rust. In the Structure chapter of Rust By Example,

There are three types of structures that can be created using the keyword struct.

  • Tuple. (Mostly named tuples)
  • Classic C-style structure.
  • unit. This has no fields and is useful when dealing with generic types.

The sample code was also posted after this, but I did not know what the "named tuple" was.
If anyone knows, please let me know.

Answer: Answer:

The English version looks like this:

There are three types of structures ("structs") that can be created using the struct keyword:

  • Tuple structs, which are, basically, named tuples.
  • The classic C structs
  • Unit structs, which are field-less, are useful for generics.

The relevant part " Tuple structs, which are, basically, named tuples. " Means "tuple structs (generally like named tuples)".
In other words, "a tuple structure is like a normal tuple with a name."

Scroll to Top