Knowledge Garden

Search

Search IconIcon to open search

Packages-Crates in Rust

Last updated Dec 1, 2022 Edit Source

# Packages - (crates)

once you have specified the name of package you want to use you need to go the Cargo.toml and add the package to the dependencies section.

1
2
[dependencies]
rand = "0.1.2" //rand package for generating nums

# scalar types

UnsignedSigned
u8i8
u16i16
u32i32
u64u64
u128i128
usizeisize

number of bits the int has, consistent accross all platforms

except for usize size of platforms pointer type can represent every memory address in the process

Also used to index into array or vector

signed ints are the same

max isize is upper bound of object and array size.

this lets it be used to calc differences between pointers and be able to address every byte within a value like a struct

the default is i32 because its generally the fastest

just because rust supports all types doesn’t mean all types are supported on all architectures!