Primitive Types - ชนิดข้อมูลพื้นฐาน
Rust มี primitive types ที่เป็นพื้นฐานของทุกโปรแกรม
Primitive Types คืออะไร
Section titled “Primitive Types คืออะไร”Primitive types คือชนิดข้อมูลพื้นฐานที่ built-in มากับภาษา ไม่ต้อง import
| หมวด | Types |
|---|---|
| Integers | i8, i16, i32, i64, i128, isize |
| Unsigned | u8, u16, u32, u64, u128, usize |
| Floats | f32, f64 |
| Text | char, str |
| Boolean | bool |
| Unit | () |
| Compound | array, slice, tuple |
| Pointers | reference, pointer, fn, never |
หมวดตัวเลข
Section titled “หมวดตัวเลข”Signed Integers
Section titled “Signed Integers”| Type | ขนาด | Range |
|---|---|---|
i8 | 1 byte | -128 to 127 |
i16 | 2 bytes | -32,768 to 32,767 |
i32 | 4 bytes | -2.1B to 2.1B |
i64 | 8 bytes | -9.2E to 9.2E |
i128 | 16 bytes | Huge |
isize | ptr size | Platform |
เข้าสู่ระบบเพื่อดูเนื้อหาเต็ม
ยืนยันตัวตนด้วยบัญชี Google เพื่อปลดล็อกบทความทั้งหมด
Login with Google