Struct::function() syntax,
rather than the ref.method() syntax.
Some other languages call
associated functions
' _______ methods'.
Front
static
Back
Method Syntax
to call a bunch of
Front
Functions
Back
Concatenation:
concatenate a &str to the end of it:
let hello = "Hello ".to_string();
let world = "world!";
let hello_world = hello + world;
Front
+
Back
Trait __________ on generic functions.
its behavior.
to constrain, or bound
Front
bounds
Back
self if it's a value on the stack,
&self if it's a reference,
and
&mut self if it's a mutable ___________ .
Front
reference
Back
Methods take a special first parameter, of which there are three variants:
self,
&self,
&mut ____
Front
self
Back
Match
Front
val => expression
Back
Destructuring
compound data type, like a struct, you can destructure it inside of a __________
Front
pattern
Back
Generics:
multiple types of _______________.
Front
arguments
Back
Traits?
functionality a type must _________.
Front
provide
Back
let greeting = "Hello there."; // greeting: &'static ____
Front
str
Back
growable, and is also guaranteed to be _____-_
Front
UTF-8
Back
ref and ref mut
reference, use the ___ keyword:
Front
ref
Back
Multiple patterns
multiple patterns with |
x = 1;
match x
1 | 2 => one or ____
Front
two
Back
Ranges
match x
1 ... 5 => one ________ five
_ => anything
Front
through
Back
Rust has two main types of strings:
&str and
________.
Front
String
Back
Chaining method calls.
call a method,
such as
foo.bar().
foo.bar().baz()?
This is called 'method __________ '.
Front
chaining
Back
Note that you normally cannot access a str directly,
but only through a &str reference. This is because str is an __________ type
Front
unsized
Back
Associated functions.
do not take a self ______________ .
Front
parameter
Back
struct Rectangle<T> ?
x: T
y: T
width: T
height: T
impl<T: PartialEq> Rectangle<T>
fn is_square(&self) -> _______
self.width == self.height
Front
bool
Back
Strings
strings are a __ _ ________ data structure.
Front
re-sizable
Back
Guards
match guards with ___
Front
if
Back
baz(bar(foo));
left-to-right
foo.bar().baz();
'method call syntax via the ____ keyword.
Front
impl
Back
Last Arm
Front
underscore _
Back
Ignoring bindings
match some_value
Ok(value) => got a value: {} value
Err(_) => an error occurred
Front
underscore _
Back
Trait bounds on generic structs?
append the bound when you declare type ___________ . Here is a new type Rectangle<T> and its operation is_square():
Front
parameters
Back
Indexing.
Because strings are valid UTF-8, they do not support :
___________
Front
indexing
Back
Builder Pattern.
only set the properties
Rust doesn't have method overloading,
named arguments,
or variable arguments.
We employ the builder ___________ instead.