[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"academy-blogs-en-1-1-all-rust-programming-data-types-guide-all--*":3,"academy-blog-translations-6fihd4eoshq37wa":96},{"data":4,"page":95,"perPage":95,"totalItems":95,"totalPages":95},[5],{"alt":6,"collectionId":7,"collectionName":8,"content":9,"cover_image":10,"cover_image_path":11,"created":12,"created_by":13,"expand":14,"id":88,"keywords":89,"locale":64,"published_at":90,"scheduled_at":13,"school_blog":86,"short_description":91,"slug":92,"status":84,"title":93,"updated":94,"updated_by":13,"views":87},"Infographic showing Rust data types categorization into Scalar and Compound types with code snippets and descriptions.","sclblg987654321","school_blog_translations","\u003Cp>In EP.4, we learned how to declare variables and manage mutability. However, variables always go hand-in-hand with \u003Cstrong>\"Data Types.\"\u003C\u002Fstrong> In Rust, every value must have a specific type to allow the compiler to ensure the program runs safely and efficiently.\u003C\u002Fp>\u003Cp>Rust is a \u003Cstrong>statically typed\u003C\u002Fstrong> language, meaning it must know the types of all variables at compile time. We can categorize Rust data types into two main groups: \u003Cstrong>Scalar\u003C\u002Fstrong> (single values) and \u003Cstrong>Compound\u003C\u002Fstrong> (grouped values).\u003C\u002Fp>\u003Ch2>1. Scalar Types\u003C\u002Fh2>\u003Cp>A scalar type represents a single value. Rust has four primary scalar types:\u003C\u002Fp>\u003Ch3>🔢 Integers\u003C\u002Fh3>\u003Cp>Integers are numbers without a fractional component. Rust provides various sizes based on memory (bits), divided into \u003Cstrong>Signed\u003C\u002Fstrong> (i) and \u003Cstrong>Unsigned\u003C\u002Fstrong> (u):\u003C\u002Fp>\u003Ctable style=\"min-width: 75px;\">\u003Ccolgroup>\u003Ccol style=\"min-width: 25px;\">\u003Ccol style=\"min-width: 25px;\">\u003Ccol style=\"min-width: 25px;\">\u003C\u002Fcolgroup>\u003Ctbody>\u003Ctr>\u003Ctd colspan=\"1\" rowspan=\"1\">\u003Cp>\u003Cstrong>Length\u003C\u002Fstrong>\u003C\u002Fp>\u003C\u002Ftd>\u003Ctd colspan=\"1\" rowspan=\"1\">\u003Cp>\u003Cstrong>Signed\u003C\u002Fstrong>\u003C\u002Fp>\u003C\u002Ftd>\u003Ctd colspan=\"1\" rowspan=\"1\">\u003Cp>\u003Cstrong>Unsigned\u003C\u002Fstrong>\u003C\u002Fp>\u003C\u002Ftd>\u003C\u002Ftr>\u003Ctr>\u003Ctd colspan=\"1\" rowspan=\"1\">\u003Cp>8-bit\u003C\u002Fp>\u003C\u002Ftd>\u003Ctd colspan=\"1\" rowspan=\"1\">\u003Cp>\u003Ccode>i8\u003C\u002Fcode>\u003C\u002Fp>\u003C\u002Ftd>\u003Ctd colspan=\"1\" rowspan=\"1\">\u003Cp>\u003Ccode>u8\u003C\u002Fcode>\u003C\u002Fp>\u003C\u002Ftd>\u003C\u002Ftr>\u003Ctr>\u003Ctd colspan=\"1\" rowspan=\"1\">\u003Cp>32-bit\u003C\u002Fp>\u003C\u002Ftd>\u003Ctd colspan=\"1\" rowspan=\"1\">\u003Cp>\u003Ccode>i32\u003C\u002Fcode> (Default)\u003C\u002Fp>\u003C\u002Ftd>\u003Ctd colspan=\"1\" rowspan=\"1\">\u003Cp>\u003Ccode>u32\u003C\u002Fcode>\u003C\u002Fp>\u003C\u002Ftd>\u003C\u002Ftr>\u003Ctr>\u003Ctd colspan=\"1\" rowspan=\"1\">\u003Cp>64-bit\u003C\u002Fp>\u003C\u002Ftd>\u003Ctd colspan=\"1\" rowspan=\"1\">\u003Cp>\u003Ccode>i64\u003C\u002Fcode>\u003C\u002Fp>\u003C\u002Ftd>\u003Ctd colspan=\"1\" rowspan=\"1\">\u003Cp>\u003Ccode>u64\u003C\u002Fcode>\u003C\u002Fp>\u003C\u002Ftd>\u003C\u002Ftr>\u003Ctr>\u003Ctd colspan=\"1\" rowspan=\"1\">\u003Cp>arch\u003C\u002Fp>\u003C\u002Ftd>\u003Ctd colspan=\"1\" rowspan=\"1\">\u003Cp>\u003Ccode>isize\u003C\u002Fcode>\u003C\u002Fp>\u003C\u002Ftd>\u003Ctd colspan=\"1\" rowspan=\"1\">\u003Cp>\u003Ccode>usize\u003C\u002Fcode>\u003C\u002Fp>\u003C\u002Ftd>\u003C\u002Ftr>\u003C\u002Ftbody>\u003C\u002Ftable>\u003Cblockquote>\u003Cp>\u003Cstrong>Note:\u003C\u002Fstrong> \u003Ccode>isize\u003C\u002Fcode> and \u003Ccode>usize\u003C\u002Fcode> depend on the architecture of the computer your program is running on (e.g., 64-bit on a Mac M4). These are primarily used when indexing collections like Arrays.\u003C\u002Fp>\u003C\u002Fblockquote>\u003Ch3>🥧 Floating-Point Types\u003C\u002Fh3>\u003Cp>Rust has two primitive types for numbers with decimal points: \u003Ccode>f32\u003C\u002Fcode> and \u003Ccode>f64\u003C\u002Fcode> (the default).\u003C\u002Fp>\u003Cp>Rust\u003C\u002Fp>\u003Cpre>\u003Ccode>let x = 2.0; \u002F\u002F f64 by default\nlet y: f32 = 3.0; \u002F\u002F explicit f32 declaration\n\u003C\u002Fcode>\u003C\u002Fpre>\u003Ch3>✅ Booleans\u003C\u002Fh3>\u003Cp>Booleans have two possible values: \u003Ccode>true\u003C\u002Fcode> and \u003Ccode>false\u003C\u002Fcode>. They are 1 byte in size.\u003C\u002Fp>\u003Cp>Rust\u003C\u002Fp>\u003Cpre>\u003Ccode>let is_active = true;\nlet is_finished: bool = false;\n\u003C\u002Fcode>\u003C\u002Fpre>\u003Ch3>🔤 Characters\u003C\u002Fh3>\u003Cp>In Rust, the \u003Ccode>char\u003C\u002Fcode> type is specified with single quotes (\u003Ccode>'\u003C\u002Fcode>) and is \u003Cstrong>4 bytes\u003C\u002Fstrong> in size. Why? Because it represents a \u003Cstrong>Unicode Scalar Value\u003C\u002Fstrong>, meaning it can store much more than just ASCII—it supports Emojis, Thai characters, and more!\u003C\u002Fp>\u003Cp>Rust\u003C\u002Fp>\u003Cpre>\u003Ccode>let c = 'z';\nlet heart_eye_emoji = '😻';\n\u003C\u002Fcode>\u003C\u002Fpre>\u003Ch2>2. Compound Types\u003C\u002Fh2>\u003Cp>Compound types can group multiple values into one type. Rust has two primitive compound types:\u003C\u002Fp>\u003Ch3>📦 Tuples\u003C\u002Fh3>\u003Cp>A tuple is a general way of grouping together a number of values with a variety of types into one compound type. \u003Cstrong>Tuples have a fixed length\u003C\u002Fstrong>: once declared, they cannot grow or shrink.\u003C\u002Fp>\u003Cp>Rust\u003C\u002Fp>\u003Cpre>\u003Ccode>let person: (&amp;str, i32, bool) = (\"Ploy\", 25, true);\n\n\u002F\u002F Destructuring to get values\nlet (name, age, status) = person;\n\n\u002F\u002F Accessing via Index (Dot notation)\nlet name = person.0;\n\u003C\u002Fcode>\u003C\u002Fpre>\u003Ch3>🔢 Arrays\u003C\u002Fh3>\u003Cp>Unlike a tuple, every element of an array must have the \u003Cstrong>same type\u003C\u002Fstrong>. Arrays in Rust have a \u003Cstrong>fixed length\u003C\u002Fstrong> and are allocated on the stack, making them incredibly fast.\u003C\u002Fp>\u003Cp>Rust\u003C\u002Fp>\u003Cpre>\u003Ccode>let months = [\"Jan\", \"Feb\", \"Mar\"];\nlet numbers: [i32; 5] = [1, 2, 3, 4, 5]; \u002F\u002F [Type; Length]\n\n\u002F\u002F Accessing elements\nlet first = numbers[0];\n\u003C\u002Fcode>\u003C\u002Fpre>\u003Cblockquote>\u003Cp>\u003Cstrong>Warning:\u003C\u002Fstrong> If you try to access an index that doesn't exist (Out of bounds), Rust will cause the program to \u003Cstrong>\"Panic\"\u003C\u002Fstrong> (exit immediately) to prevent memory insecurity.\u003C\u002Fp>\u003C\u002Fblockquote>\u003Cp>\u003C\u002Fp>\u003Cdiv data-type=\"horizontalRule\">\u003Chr>\u003C\u002Fdiv>\u003Ch2>Summary\u003C\u002Fh2>\u003Cp>Choosing the right type not only saves memory but also allows the Rust compiler to act as your \"assistant,\" verifying the logic and correctness of your code.\u003C\u002Fp>\u003Cp>In \u003Cstrong>EP.6\u003C\u002Fstrong>, get ready for \u003Cstrong>Control Flow\u003C\u002Fstrong>! We will explore how to use \u003Ccode>if-else\u003C\u002Fcode> and various types of loops to make our programs handle complex conditions.\u003C\u002Fp>\u003Ch2>🎯 Stay Tuned with Superdev Academy:\u003C\u002Fh2>\u003Cp>Don't miss out on deep-dive technical articles and updates. Follow us on all platforms:\u003C\u002Fp>\u003Cul>\u003Cli>\u003Cp>🔵 \u003Cstrong>Facebook:\u003C\u002Fstrong> \u003Ca target=\"_blank\" rel=\"noopener\" class=\"ng-star-inserted\" href=\"https:\u002F\u002Fwww.facebook.com\u002Fsuperdev.academy.th\">Superdev Academy Thailand\u003C\u002Fa>\u003C\u002Fp>\u003C\u002Fli>\u003Cli>\u003Cp>🎬 \u003Cstrong>YouTube:\u003C\u002Fstrong> \u003Ca target=\"_blank\" rel=\"noopener\" class=\"ng-star-inserted\" href=\"https:\u002F\u002Fwww.youtube.com\u002F@SuperdevAcademy\">Superdev Academy Channel\u003C\u002Fa>\u003C\u002Fp>\u003C\u002Fli>\u003Cli>\u003Cp>📸 \u003Cstrong>Instagram:\u003C\u002Fstrong> \u003Ca target=\"_blank\" rel=\"noopener\" class=\"ng-star-inserted\" href=\"https:\u002F\u002Fwww.instagram.com\u002Fsuperdevacademy\u002F\">@superdevacademy\u003C\u002Fa>\u003C\u002Fp>\u003C\u002Fli>\u003Cli>\u003Cp>🎬 \u003Cstrong>TikTok:\u003C\u002Fstrong> \u003Ca target=\"_blank\" rel=\"noopener\" class=\"ng-star-inserted\" href=\"https:\u002F\u002Fwww.tiktok.com\u002F@superdevacademy?lang=th-TH\">@superdevacademy\u003C\u002Fa>\u003C\u002Fp>\u003C\u002Fli>\u003Cli>\u003Cp>🌐 \u003Cstrong>Website:\u003C\u002Fstrong> \u003Ca target=\"_blank\" rel=\"noopener noreferrer nofollow\" href=\"http:\u002F\u002Fsuperdevacademy.com\">superdevacademy.com\u003C\u002Fa>\u003C\u002Fp>\u003C\u002Fli>\u003C\u002Ful>\u003Cp>\u003C\u002Fp>","100lwcdz8dpy_jh6z4bzi9n.png","https:\u002F\u002Ftwsme-r2.tumwebsme.com\u002Fsclblg987654321\u002Fq8fpbr9higqzif0\u002F100lwcdz8dpy_jh6z4bzi9n.png","2026-04-03 10:57:48.187Z","",{"keywords":15,"locale":58,"school_blog":68},[16,23,28,33,38,43,48,53],{"collectionId":17,"collectionName":18,"created":19,"created_by":13,"id":20,"name":21,"updated":22,"updated_by":13},"sclkey987654321","school_keywords","2026-03-04 08:20:08.348Z","ux2m77tsy8v19bg","Rust Programming","2026-04-10 16:07:25.602Z",{"collectionId":17,"collectionName":18,"created":24,"created_by":13,"id":25,"name":26,"updated":27,"updated_by":13},"2026-03-23 03:08:56.729Z","ttp78s7jayewgl4","Rust","2026-04-10 16:14:44.997Z",{"collectionId":17,"collectionName":18,"created":29,"created_by":13,"id":30,"name":31,"updated":32,"updated_by":13},"2026-04-03 10:51:22.578Z","ckgl4w4nk4uirqs","Data Types","2026-04-10 16:14:47.014Z",{"collectionId":17,"collectionName":18,"created":34,"created_by":13,"id":35,"name":36,"updated":37,"updated_by":13},"2026-04-03 10:51:34.251Z","a38yxdu4yv4sp47","Scalar types","2026-04-10 16:14:47.107Z",{"collectionId":17,"collectionName":18,"created":39,"created_by":13,"id":40,"name":41,"updated":42,"updated_by":13},"2026-04-03 10:51:41.429Z","kq299ibv4vo4jth","Compound types","2026-04-10 16:14:47.227Z",{"collectionId":17,"collectionName":18,"created":44,"created_by":13,"id":45,"name":46,"updated":47,"updated_by":13},"2026-03-23 03:26:43.307Z","pf009wnev852vvt","Rust tutorial","2026-04-10 16:14:45.235Z",{"collectionId":17,"collectionName":18,"created":49,"created_by":13,"id":50,"name":51,"updated":52,"updated_by":13},"2026-04-03 10:57:34.421Z","azixuoag5jisout","Backend Development","2026-04-10 16:14:47.389Z",{"collectionId":17,"collectionName":18,"created":54,"created_by":13,"id":55,"name":56,"updated":57,"updated_by":13},"2026-03-04 08:44:11.146Z","gms2qr4xg6qv65e","Superdev Academy","2026-04-10 16:12:41.207Z",{"code":59,"collectionId":60,"collectionName":61,"created":62,"flag":63,"id":64,"is_default":65,"label":66,"updated":67},"en","pbc_1989393366","locales","2026-01-22 11:00:02.726Z","twemoji:flag-united-states","qv9c1llfov2d88z",false,"English","2026-04-10 15:42:46.825Z",{"category":69,"collectionId":70,"collectionName":71,"expand":72,"id":86,"views":87},"mfqe235iv6x1or8","pbc_2105096300","school_blogs",{"category":73},{"blogIds":74,"collectionId":75,"collectionName":76,"created":77,"created_by":13,"id":69,"image":78,"image_alt":13,"image_path":79,"label":80,"name":81,"priority":82,"publish_at":83,"scheduled_at":13,"status":84,"updated":85,"updated_by":13},[],"sclcatblg987654321","school_category_blogs","2026-03-16 04:40:07.104Z","47vt5s1gglj_tz0b90vnge.png","https:\u002F\u002Ftwsme-r2.tumwebsme.com\u002Fsclcatblg987654321\u002Fmfqe235iv6x1or8\u002F47vt5s1gglj_tz0b90vnge.png",{"en":81,"th":81},"Rust The Series",2,"2026-03-16 04:40:09.199Z","published","2026-04-25 02:32:15.619Z","6fihd4eoshq37wa",113,"q8fpbr9higqzif0",[20,25,30,35,40,45,50,55],"2026-04-07 02:56:20.609Z","Dive into Rust’s data types, covering Scalar types like integers and characters, and Compound types like Tuples and Arrays. Learn how Rust ensures memory safety through strict static typing.","rust-programming-data-types-guide","Basic Data Types: Exploring Scalar and Compound Types | Rust The Series EP.5","2026-04-22 07:11:54.653Z",1,{"th":97,"en":92},"rust-series-ep5-data-types"]