Coding Packets Blog

Author Archives: Coding Packets Blog

Rust Notes: Enums

An enum is a type which can be ONE of a FEW different variants. // Create an instance of the enum variants with the double colon. let blah = StuffAndThings::Blah; let bleh = StuffAndThings::Bleh(42); let stuff = StuffAndThings::Stuff(String::from("Stuff"), true); let things =...continue reading

Rust Notes: Vectors

A vector is a collection of items of the same type. Vector Considerations When an empty vector is created with Vec::new it is un-allocated until elements are pushed into it. A vector with elements has allocated memory and lives on the heap. A vector is represented as a pointer to the...continue reading

Rust Notes: Arrays

An array is a sequence of values, of the same type. A tuple is defined with square brackets []. Array Considerations Arrays live on the stack by default and have a fixed size. Traits are only implemented on an array with a size of 32 or less. Arrays with a size greater than 32 lose...continue reading

Rust Notes: Tuples

A tuple is a sequence of values, which can be of different types. A tuple is defined with circle brackets (). Tuple Considerations The number of elements in a tuple is known as its arity. Traits are only implemented on a tuple with an arity of 12 or less. Tuples with an arity...continue reading

1 3 4 5 6 7 28