{"schemaVersion":"1.0","title":"Rust Data Types Field Guide API","description":"Structured beginner and expert guidance for the Rust data types shown on the visual reference poster.","count":7,"types":[{"slug":"str-slice","typeName":"&str","category":"text","accent":"blue","eyebrow":"STRING SLICE","summary":"A borrowed view into valid UTF-8 text.","code":"let greeting: &str =\n    \"Hello, Rust!\";","beginner":"Use &str when code only needs to read text owned somewhere else. String literals such as \"hello\" have the type &'static str.","mentalModel":"Think of it as an address plus a byte length. It points at text without owning or copying that text.","useWhen":["Accepting read-only text in function parameters","Taking a substring on a valid UTF-8 boundary","Using string literals"],"watchFor":["It cannot outlive the text it borrows.","Indexing by a numeric position is not allowed because UTF-8 characters can use multiple bytes."],"expertNote":"&str is a dynamically sized type behind a fat pointer containing a data pointer and length. Prefer &str over &String in APIs.","relatedTypes":["String","&[u8]","Cow<'a, str>"],"officialDocs":"https://doc.rust-lang.org/std/primitive.str.html"},{"slug":"string","typeName":"String","category":"text","accent":"blue","eyebrow":"OWNED STRING","summary":"Growable, owned UTF-8 text stored on the heap.","code":"let mut name =\n    String::from(\"Alice\");","beginner":"Use String when your value must own its text, change it, or keep it after borrowed input goes away.","mentalModel":"Think of it as a handle with a pointer, current byte length, and allocated capacity. The handle owns the heap buffer.","useWhen":["Building or editing text","Storing text in a struct","Returning newly created text"],"watchFor":["Cloning copies the text data and can allocate.","Length and capacity are measured in bytes, not visible characters."],"expertNote":"String maintains UTF-8 validity and has the same three-word representation as Vec<u8>. Borrow it as &str for read-only APIs.","relatedTypes":["&str","Vec<u8>","Box<str>"],"officialDocs":"https://doc.rust-lang.org/std/string/struct.String.html"},{"slug":"i32","typeName":"i32","category":"integer","accent":"green","eyebrow":"SIGNED INTEGER","summary":"A 32-bit whole number that supports negative values.","code":"let count: i32 = -100;","beginner":"i32 is Rust’s default integer type when the compiler has no reason to choose another integer type.","mentalModel":"It uses 32 bits and stores values from −2,147,483,648 through 2,147,483,647.","useWhen":["General-purpose counters and measurements","Values that may be negative","Interoperating with many C-style integer APIs"],"watchFor":["Arithmetic can overflow the fixed range.","Use checked, saturating, wrapping, or overflowing methods when overflow behavior matters."],"expertNote":"Signed integers use two’s-complement representation. In optimized builds, ordinary overflow is not a substitute for intentional wrapping arithmetic.","relatedTypes":["i64","isize","u32"],"officialDocs":"https://doc.rust-lang.org/std/primitive.i32.html"},{"slug":"u64","typeName":"u64","category":"integer","accent":"green","eyebrow":"UNSIGNED INTEGER","summary":"A 64-bit whole number whose minimum value is zero.","code":"let id: u64 = 1048576;","beginner":"u64 stores large non-negative values from 0 through 18,446,744,073,709,551,615.","mentalModel":"All 64 bits contribute to magnitude because no bit is needed to represent a negative sign.","useWhen":["Large counters and identifiers","Bit masks and binary data","File sizes or protocol fields defined as 64-bit unsigned values"],"watchFor":["Subtracting below zero can overflow.","Unsigned values do not automatically make invalid negative domain values impossible at input boundaries."],"expertNote":"Choose integer widths from domain and interoperability requirements rather than memory micro-optimizations. Use usize for indexing collections.","relatedTypes":["u32","usize","i64"],"officialDocs":"https://doc.rust-lang.org/std/primitive.u64.html"},{"slug":"bool","typeName":"bool","category":"scalar","accent":"purple","eyebrow":"BOOLEAN","summary":"A logical value that is either true or false.","code":"let is_active: bool = true;","beginner":"Use bool for yes-or-no state and for conditions in if, while, and match expressions.","mentalModel":"It represents one of exactly two valid logical states: true or false.","useWhen":["Testing a condition","Recording a simple on/off state","Combining logic with &&, ||, and !"],"watchFor":["Several related booleans can hide a richer state model; an enum may be clearer.","Rust does not implicitly convert integers or pointers to bool."],"expertNote":"bool occupies one byte, but arrays of bool are not bit-packed. Only 0 and 1 are valid bit patterns when crossing unsafe boundaries.","relatedTypes":["Option<T>","enum","AtomicBool"],"officialDocs":"https://doc.rust-lang.org/std/primitive.bool.html"},{"slug":"f64","typeName":"f64","category":"scalar","accent":"yellow","eyebrow":"FLOAT","summary":"A double-precision IEEE 754 floating-point number.","code":"let pi: f64 = 3.14159;","beginner":"Use f64 for measurements and calculations that need fractional values and can tolerate approximation.","mentalModel":"It stores a sign, exponent, and fraction. This gives a huge range, but many decimal values cannot be represented exactly.","useWhen":["Scientific and statistical calculations","Graphics and physical measurements","General decimal calculations where tiny rounding error is acceptable"],"watchFor":["Do not compare calculated floats for exact equality without considering tolerance.","NaN is not equal to itself, and f64 does not implement Ord."],"expertNote":"f64 follows IEEE 754 binary64 semantics. For deterministic ordering use total_cmp; for money use an integer minor unit or a decimal type.","relatedTypes":["f32","i64","Ordering"],"officialDocs":"https://doc.rust-lang.org/std/primitive.f64.html"},{"slug":"char","typeName":"char","category":"scalar","accent":"purple","eyebrow":"UNICODE CHAR","summary":"One Unicode scalar value stored in four bytes.","code":"let initial: char = 'R';","beginner":"A char represents one Unicode scalar value, such as 'R' or '🦀'. Single quotes create chars; double quotes create strings.","mentalModel":"It is a 32-bit value restricted to valid Unicode scalar values. One char is not always one user-perceived character.","useWhen":["Processing text one Unicode scalar at a time","Character classification","Representing a delimiter or symbol"],"watchFor":["Accents and emoji can contain multiple scalar values.","A char is always four bytes even though its UTF-8 encoding may use one to four bytes."],"expertNote":"char excludes Unicode surrogate code points. Grapheme-aware UI work needs Unicode segmentation rather than str::chars alone.","relatedTypes":["&str","u32","Iterator<Item = char>"],"officialDocs":"https://doc.rust-lang.org/std/primitive.char.html"}],"discovery":{"openapi":"/openapi.json","llms":"/llms.txt","detailPattern":"/api/rust-types/{slug}"}}