What Are Tuple Structs in Rust?

Tuple structs are named types containing ordered fields without individual names, defined using parentheses.

Tuple structs are named data structures that contain only fields without named identifiers, defined using parentheses instead of braces. They are useful when you want to give a type a name but don't need to name its individual parts, often used to wrap values or represent simple data like RGB colors.

struct WriteMessage(String);
struct ChangeColorMessage(i32, i32, i32);

fn main() {
    let msg = WriteMessage("Hello".to_string());
    let color = ChangeColorMessage(255, 0, 0);
}