| Rust | C++ | C# | Python |
|---|---|---|---|
| i8, i16, i32, i64, i128, isize | int8_t … int64_t, ptrdiff_t | sbyte, short, int, long | int (arbitrary precision) |
| u8, u16, u32, u64, u128, usize | uint8_t … uint64_t, size_t | byte, ushort, uint, ulong | - |
| Rust | C++ | C# | Python |
|---|---|---|---|
| f32, f64 | float, double, long double | float (32-bit), double (64-bit) | float (always 64-bit) |
bool in all four languages; values are
true and false. C++ historically treated any non-zero integer
as truthy, but modern C++ and all other listed languages require an explicit bool in
conditional expressions.
char is a Unicode scalar value (4 bytes).
C++ char is implementation-defined (typically 1 byte, ASCII or UTF-8 byte).
C# char is a UTF-16 code unit (2 bytes). Python has no separate char type
- a single-character string serves the same role.
t.0, C++: std::get<0>(t)):
enum.Enum provides named constants but not per-variant data.
String (owned, heap-allocated, valid
UTF-8) from &str (borrowed slice of UTF-8 bytes). Indexing by integer
is not allowed because a UTF-8 scalar is 1–4 bytes.
std::string owns heap memory (raw bytes, UTF-8 by
convention). std::string_view is a non-owning reference analogous to
Rust’s &str; it does not own or null-terminate.
string is an immutable reference type on the heap,
encoded as UTF-16. System.Span<char> provides a low-allocation slice
for processing.
str is an immutable sequence of Unicode code points.
Indexing yields a code point, not a byte. bytes holds raw binary data and
does not interpret encoding.
f64.