Rust program to create a tuple

Rust | Tuple Example: Write a program to create a tuple.
Last Updated : October 18, 2021

Problem Statement

In this program, we will create a tuple to store employee information, and then we will print employee information.

Program/Source Code

The source code to create a tuple is given below. The given program is compiled and executed successfully.

// Rust program to create a tuple

fn main() {
   let MyTuple:(i32,&str,u8) = (101,"Dhairya Pratap",25);
   println!("Employee information:\n{:?}",MyTuple);
}

Output

Employee information:
(101, "Dhairya Pratap", 25)

Explanation

Here, we created a tuple MyTuple that contains employee information. Then we printed the created tuple.

Rust Tuples Programs »



Advertisement
Advertisement


Comments and Discussions!

Load comments ↻


Advertisement
Advertisement
Advertisement

Copyright © 2025 www.includehelp.com. All rights reserved.