added notes did more stuff

This commit is contained in:
2022-12-15 12:25:57 -05:00
parent 055e0d69ae
commit 6db7d9edf7
6 changed files with 146 additions and 0 deletions

83
notes Normal file
View File

@ -0,0 +1,83 @@
const is a thing
const convention is all upper with _
const evaluation info: https://doc.rust-lang.org/reference/const_eval.html
you can add arbitray scopes to modify local variables or for other purposes!
{
some random shit;
}
https://doc.rust-lang.org/book/ch03-02-data-types.html
scalars:
ints
floats
bools
chars
integer types:
8-bit i8 u8
16-bit i16 u16
32-bit i32 u32
64-bit i64 u64
128-bit i128 u128
arch isize usize
number literals
decimal 1_024
hex 0xff
oct 0o77
binary 0b1100_1011_0100_0001
byte b'E'
release builds have no overflow wrap checking
don't rely on this behavior
explicitly use
`wrapping_*` methods to do this
such as wrapping_add
Return the None value if there is overflow with the checked_* methods
Return the value and a boolean indicating whether there was overflow with the overflowing_* methods
wtf is this:
Saturate at the values minimum or maximum values with saturating_* methods
there are f32 and f64 floats. f64 is default cause they are about the same speed
normal math operators
int division is floor
remainder % exists
all operators:
https://doc.rust-lang.org/book/appendix-02-operators.html
type annotation:
let var: type = val;
Rusts char type is four bytes in size and represents a Unicode Scalar Value
Compound types
primitive compound types:
tuples
arrays
Tuples:
fixed length combo of types
type is ()
pulling out the elements of a tuple into individual variables is called destructuring
Arrays:
fixed type fixed length
[]
init:
let a: [1, 2, 3];
let a: [3, 0]; // set every element to same value
reference:
let first = a[0];
they are allocated on stack