ADVERTISEMENT
ADVERTISEMENT

Rust program to create an alias of built-in data type

Here, we are going to learn how to create an alias of built-in data type in Rust programming language?
Submitted by Nidhi, on September 21, 2021

Problem Solution:

Here, we will create an alias or alternative name of the i32 datatype. Then we will create a variable using an alias name.

Program/Source Code:

The source code to create an alias of built-in data type is given below. The given program is compiled and executed successfully.

// Rust program to create an alias 
// of built-in data type

fn main() {
    type int=i32;
    
    let mut num:int=1024;  
    
    println!("Number: {}",num);
}

Output:

Number: 1024

Explanation:

Here, we created the alias of the i32 data type using the type keyword. Then we created a variable using created alias name and printed the value of the variable.

Rust Basic Programs »



ADVERTISEMENT



ADVERTISEMENT



Comments and Discussions


ADVERTISEMENT

ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.