Terms Flashcards
Statically typed
Data type of each variable must be known at compile time.
What are Rusts four primary scalar types?
Integers, Floating points, Characters, Booleans.
What is an integer data type?
A number without a fractional part.
What is a panic() in rust?
When a program exits with an error.
How does Rust handle integer overflow?
At runtime when debugging: it panics() At runtime on release, it wraps (i.e., from 255 -> 1).
What memory does a Boolean value take up?
One byte, nom.
How are character literals differentiated from string literals in Rust?
Strings use double quotes, characters use single quotes.
What is an approximate CS definition of a tuple?
An immutable ordered sequence of elements.
How do arrays differ from tuples in Rust?
They are declared with square brackets instead of round, all elements are of the same data type.
What is the difference between a statement and an expression?
A statement is an instruction to perform some action, whereas an expression evaulates code to a resulting value.
What happens at the e.o.l with a statement or expression in Rust?
Statements end in a semi colon, expressions do not.
What is the difference between shadowing and mutability?
When a mutable variable is modified, the value in memory is modified. When an immutable variable is shadowed, a new memory location is used to store a new value - with the variable name. The old memory location is unused.
What kind of loops does Rust have?
while, for, loop
What is the stack?
A memory structure that is strictly first in last out. Push onto stack, or pop off the stack.
What is the heap?
A memory structure that allows “random” storage and retrieval of allocations.