Skip to content

Instantly share code, notes, and snippets.

@AstragoDE
Last active April 8, 2023 17:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AstragoDE/84bb957d7b1a519170dce7aa912fe352 to your computer and use it in GitHub Desktop.
Save AstragoDE/84bb957d7b1a519170dce7aa912fe352 to your computer and use it in GitHub Desktop.
Dataypes in Rust (by ChatGPT)

Signed Integer Types:

Type Minimum Value Maximum Value
i8 -128 127
i16 -32,768 32,767
i32 -2,147,483,648 2,147,483,647
i64 -9,223,372,036,854,775,808 9,223,372,036,854,775,807

Unsigned Integer Types:

Type Minimum Value Maximum Value
u8 0 255
u16 0 65,535
u32 0 4,294,967,295
u64 0 18,446,744,073,709,551,615

Floating-point Types:

Type Minimum Value Maximum Value
f32 1.175494351e-38 3.402823466e+38
f64 2.2250738585072014e-308 1.7976931348623157e+308

Other Types:

  • bool: Represents a boolean value, either true or false.
  • char: Represents a single Unicode character.
  • str: Represents a string slice, which is an immutable sequence of Unicode characters.
  • String: Represents a heap-allocated string, which is a growable, UTF-8 encoded string.
  • Vec<T>: Represents a growable, heap-allocated array of values of type T.
  • Option<T>: Represents an optional value that may or may not be present.
  • Result<T, E>: Represents the result of an operation that can either be a success value of type T or an error value of type E.
  • () (unit): Represents an empty tuple or unit value, which has only one possible value ().
  • Box<T>: Represents a heap-allocated, single ownership smart pointer to a value of type T.
  • Rc<T>: Represents a reference-counted smart pointer to a value of type T that allows multiple ownership.
  • Arc<T>: Represents an atomically reference-counted smart pointer to a value of type T that allows multiple ownership across threads.

Please note that this list is not exhaustive and there may be other types in Rust that are not listed here. Always refer to the Rust documentation or the Rust standard library for accurate and up-to-date information on Rust types and their properties.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment