

RUST Data Types
RUST support the below primitive data types:Primitive data types Supported By RUST:
- bool
- char
- Signed int
- Unsigned int
- Integer
- Float & Double
Other data types Supported By RUST:
- Array
- Tuple
- Slice
- String
Boolean Data Type Example:
fn main() {
let is_Available= true;
let explcit_Is_Available:bool = true;
println!("is_Available: {}", is_Available);
}
Char Data Type Example:
fn main() {
let letter = 'a';
let sigma = 'Σ';
let emoji = '❤';
let coffee = '☕';
println!("{}", letter);
println!("{}", sigma);
println!("{}", emoji);
println!("{}", coffee);
}
Float & Double Example:
fn main() {
let float:f32 = 3.123456;
let double:f64 = 3.123456789012345;
println!("Float: (6 digit precision) {}", float);
println!("Double: (15 digit precision) {}", double);
}
Integer Example:
fn main() {
let number:u8 = 256;
println!("u8: {}", number);
}
Integer Types in Rust
Length | Signed | Unsigned |
---|---|---|
8-bit | i8 | u8 |
16-bit | i16 | u16 |
32-bit | i32 | u32 |
64-bit | i64 | u64 |
128-bit | i128 | u128 |
arch | isize | usize |
Conclusion
In this page (written and validated by A. Gawali) you learned about Rust Data Types . What's Next? If you are interested in completing Rust tutorial, your next topic will be learning about: Rust Constant.
Incorrect info or code snippet? We take very seriously the accuracy of the information provided on our website. We also make sure to test all snippets and examples provided for each section. If you find any incorrect information, please send us an email about the issue: mockstacks@gmail.com.
Share On: |
Mockstacks was launched to help beginners learn programming languages; the site is optimized with no Ads as, Ads might slow down the performance. We also don't track any personal information; we also don't collect any kind of data unless the user provided us a corrected information. Almost all examples have been tested. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. By using Mockstacks.com, you agree to have read and accepted our terms of use, cookies and privacy policy.