Title: Theory / Unimportant / CS / Programming / Rust / Tutorial / Rust
Tags: computer_to_instruction declaration todo_declaration automatedNewLineAfterCommaSpace seen_description comment type

Name: Rustfmt
Definition: ensures a consistent coding style across developers.
Page: https://doc.rust-lang.org/book/ch00-00-introduction.html
Chapter: 0
Context: Rust

Extension: rs
Description: Rust code source
Other fields (not shown on cards):
Page: https://doc.rust-lang.org/book/ch00-00-introduction.html
Chapter: 0

Instruction: rustc foo.rs
Page: https://doc.rust-lang.org/book/ch00-00-introduction.html
Effect: Compile foo.rs to foo executable
Chapter: 0

Instruction: fn main() {
  foo
}
Page: https://doc.rust-lang.org/book/ch00-00-introduction.html
Meaning: Execute foo when the program start
Language: Rust
Chapter: 0

Name: Macro name
Definition: Name ending with !
Page: https://doc.rust-lang.org/book/ch00-00-introduction.html
Chapter: 0
Context: rust

Instruction: ;
Page: https://doc.rust-lang.org/book/ch00-00-introduction.html
Effect: Indicate the end of an expression
Language: rust
Chapter: 0

Name: Rustaceans
Definition: Rust programmers
Page: https://doc.rust-lang.org/book/ch00-00-introduction.html
Chapter: 0
Context: rust

Instruction: println!(
  foo,
  bar_1,
  ...,
  bar_n
)
Page: https://doc.rust-lang.org/book/ch00-00-introduction.html
Effect: Print foo to terminal, with the i-th {} being replaced by bar_i
Language: Rust
Chapter: 0

Instruction: use foo_1::...::foo_n;
Page: https://doc.rust-lang.org/book/ch00-00-introduction.html
Meaning: Allow to use foo_n as shorthand for foo_1::...::foo_n
Language: Rust
Chapter: 0

Name: prelude
Definition: The part of rust loaded with every programs
Page: https://doc.rust-lang.org/book/ch00-00-introduction.html
Chapter: 0
Context: Rust

Instruction: let foo = bar;
Page: https://doc.rust-lang.org/book/ch03-01-variables-and-mutability.html
Meaning: Evaluate bar and move/copy it's value to immutable variable foo
Language: Rust
Chapter: 3

Instruction: let mut foo = bar;
Page: https://doc.rust-lang.org/book/ch03-01-variables-and-mutability.html
Meaning: Evaluate bar and move/copy it's value to mutable variable foo
Language: Rust
Chapter: 3

Language: Rust
Abbreviation: // foo
Documentation: If documentation occurs inside the document code
//! foo
/*! foo*/
If documentation occurs above the documented code
/** foo*/
/// foo
Other fields (not shown on cards):
Chapter: 0
Comment: /// foo
Page: https://doc.rust-lang.org/book/ch00-00-introduction.html
https://doc.rust-lang.org/book/ch03-04-comments.html
https://doc.rust-lang.org/book/ch14-02-publishing-to-crates-io.html
https://doc.rust-lang.org/reference/comments.html

Name: An associated function to type
Definition: A function associated to type and not to an instance
Page: https://doc.rust-lang.org/book/ch00-00-introduction.html
Chapter: 0
Context: Rust
Notation: type::function
Extra: static function in other language

Typ: String
Meaning: UTF-8 encoded string that can grow (wrapper around Vec<u8>)
Page: https://doc.rust-lang.org/book/ch00-00-introduction.html
Language: Rust
Chapter: 0

Typ: std::id::Stdin
Meaning: Handle the standard input for the terminal
Page: https://doc.rust-lang.org/book/ch00-00-introduction.html
Language: Rust
Chapter: 0

Typ: std::id::Stdout
Meaning: Handle the standard output for the terminal
Page: https://doc.rust-lang.org/book/ch00-00-introduction.html
Language: Rust
Chapter: 0

Instruction: &mut foo
Page: https://doc.rust-lang.org/book/ch00-00-introduction.html
Meaning: Pass the variable foo by reference and allow the function to modify it
Language: Rust function call argument
Chapter: 0

Instruction: stdin().read_line(&mut foo)
Page: https://doc.rust-lang.org/book/ch00-00-introduction.html
Effect: Read a line on terminal and put it in variable foo
Language: Rust
Chapter: 0
Returns: std::io::Result stating whether read was done correctly
Variables: foo: String

Instruction: foo = bar
Page: https://doc.rust-lang.org/book/ch03-01-variables-and-mutability.html
Effect: Evaluate bar and assign its value to foo
Context: Rust
Chapter: 3
Assuming: foo is mutable

Instruction: const FOO: bar = plop;
Page: https://doc.rust-lang.org/book/ch03-01-variables-and-mutability.html
Meaning: Define FOO to be a constant of type bar with value plop
Chapter: 3
Assuming: plop of type bar and constant

Name: A shadowed variable
Definition: A variable whose value is not accessible anymore because another variable with the same name was defined
Page: https://doc.rust-lang.org/book/ch03-01-variables-and-mutability.html
Chapter: 3

Typ: in
Meaning: Signed integer with n bits
Page: https://doc.rust-lang.org/book/ch03-01-variables-and-mutability.html
Chapter: 3
Variables: n a power of 2 between 8 and 128

Typ: un
Meaning: Unsigned integer with n bits
Page: https://doc.rust-lang.org/book/ch03-01-variables-and-mutability.html
Chapter: 3
Variables: n a power of 2 between 8 and 128

Typ: usize
Meaning: Unsigned integer with as many bit as the computer architecture
Page: https://doc.rust-lang.org/book/ch03-01-variables-and-mutability.html
Chapter: 3
Variables: n a power of 2 between 8 and 128

Typ: isize
Meaning: signed integer with as many bit as the computer architecture
Page: https://doc.rust-lang.org/book/ch03-01-variables-and-mutability.html
Chapter: 3
Variables: n a power of 2 between 8 and 128

Name: Panicking
Definition: Exiting with error
Page: https://doc.rust-lang.org/book/ch03-01-variables-and-mutability.html
Chapter: 3
Context: Rust

Question: What occurs in case of overflow?
Answer: In debug mode banic,  in release flag two complement wrapping
Page: https://doc.rust-lang.org/book/ch03-01-variables-and-mutability.html
Chapter: 3
Context: Rust

Typ: fn
Meaning: n bits floating point
Page: https://doc.rust-lang.org/book/ch03-01-variables-and-mutability.html
Language: Rust
Chapter: 3

Typ: bool
Meaning: boolean
Page: https://doc.rust-lang.org/book/ch03-01-variables-and-mutability.html
Language: Rust
Chapter: 3

Typ: char
Meaning: unicode 4-byte character
Page: https://doc.rust-lang.org/book/ch03-01-variables-and-mutability.html
Language: Rust
Chapter: 3

Typ: (t_1, ..., t_n)
Meaning: Tuple with n element, ith element is t_i
Page: https://doc.rust-lang.org/book/ch03-01-variables-and-mutability.html
Language: Rust
Chapter: 3

Instruction: (
  v_1,
  ...,
  v_n
)
Page: https://doc.rust-lang.org/book/ch03-01-variables-and-mutability.html
Effect: Evaluate each v_i
Language: Rust
Chapter: 3
Returns: A tuple of n element, the ith having value of v_i

Instruction: [v_1, ..., v_n]
Page: https://doc.rust-lang.org/book/ch03-01-variables-and-mutability.html
Effect: Evaluate each v_i
Language: Rust
Chapter: 3
Returns: An array with n element, the ith having value of v_i
Assuming: each v_i has the same type

Typ: [t;n]
Meaning: Array of type t with n elements
Page: https://doc.rust-lang.org/book/ch03-01-variables-and-mutability.html
Language: Rust
Chapter: 3

Instruction: [v;n]
Page: https://doc.rust-lang.org/book/ch03-01-variables-and-mutability.html
Effect: Evaluate v and n
Language: Rust
Chapter: 3
Returns: An array with n elements v

Instruction: ar[i]
Page: https://doc.rust-lang.org/book/ch03-01-variables-and-mutability.html
Effect: Evaluate i and ar
Language: Rust
Chapter: 3
Returns: The i th element of ar
Variables: ar an array
i an int

Question: How are function name in rust
Answer: snake_case
Page: https://doc.rust-lang.org/book/ch03-01-variables-and-mutability.html
Chapter: 3
Context: Rust

Question: How are variable name in rust
Answer: snake_case
Page: https://doc.rust-lang.org/book/ch03-01-variables-and-mutability.html
Chapter: 3
Context: Rust

Instruction: fun(
  a_1,
  ...,
  a_n
)
Page: https://doc.rust-lang.org/book/ch03-01-variables-and-mutability.html
Effect: Evaluate each a_i and fun. Then call fun on the values of (a_1, ..., a_n)
Language: Rust
Chapter: 3

Instruction: fn fun<T_1,
  ...,
  T_m,
  'a_1,
  ...,
  'a_p>(
  pat_1:t_1,
  ...,
  pat_n:t_n
) {
  plop
}
Page: https://doc.rust-lang.org/book/ch03-01-variables-and-mutability.html
Meaning: Define a function fun with m generics and n arguments. In each type,
  T_i is replaced by an actual type,
  'a_i a lifetime and pat_i is matched against the ith value of the function call,
  whose type must be t_i
Language: Rust
Chapter: 3

Name: Parameter
Definition: A variable used in a function
Page: https://doc.rust-lang.org/book/ch03-01-variables-and-mutability.html
Chapter: 3
Context: Rust

Name: argument
Definition: A variable used in a function call
Page: https://doc.rust-lang.org/book/ch03-01-variables-and-mutability.html
Chapter: 3
Context: Rust

Name: Statement
Definition: instructions that perform some action and do not return a value.
Page: https://doc.rust-lang.org/book/ch03-01-variables-and-mutability.html
Chapter: 3
Context: Rust
Example: Function definition
Example2: assignment
Example3: A block of statements

Instruction: {
  s_1;
  ...
  s_n;
  e
}
Page: https://doc.rust-lang.org/book/ch03-01-variables-and-mutability.html
Effect: Evaluate each s_i in this order and e
Language: Rust
Chapter: 3
Returns: The value of e
Variables: s_1, ..., s_n statements
e expression

Instruction: {
  s_1;
  ...
  s_n;
}
Page: https://doc.rust-lang.org/book/ch03-01-variables-and-mutability.html
Effect: Evaluate each s_i in this order
Language: Rust
Chapter: 3
Variables: s_1, ..., s_n statements

Instruction: fn fun<T_1,
  ..., T_m,
  'a_1,
  ...,
  'a_p>(
  pat_1:t_1,
  ..., pat_n:t_n
) -> t{
  plop
}
Page: https://doc.rust-lang.org/book/ch03-03-how-functions-work.html
Meaning: Define a function fun with n arguments,
  the ith called a_i of type t_i,
  returning type t,
  matching ith argument against pattern pat_i calling this function execute plop.
Language: Rust
Chapter: 3
Variables: s_1,
  ...,
  s_n statements
e expression

Instruction: if p {e_1} else {e_2}
Page: https://doc.rust-lang.org/book/ch03-05-control-flow.html
Effect: If p is true, execute e_1, else e_2
Language: Rust
Chapter: 3
Returns: If p is true, the value of e_1, else the one of e_2
Variables: p a boolean
e_1, e_2: expressions

Instruction: if p {e}
Page: https://doc.rust-lang.org/book/ch03-05-control-flow.html
Effect: If p is true, execute e_1
Language: Rust
Chapter: 3
Variables: p a boolean
e: expressions

Instruction: loop {e}
Page: https://doc.rust-lang.org/book/ch03-05-control-flow.html
Effect: Executing e infinitely often
Language: Rust
Chapter: 3
Returns: The value returned by the last execution of e

Instruction: break e
Page: https://doc.rust-lang.org/book/ch03-05-control-flow.html
Effect: Execute e, leave the innermost loop and return the value of e
Language: Rust
Chapter: 3
Variables: e: expression

Instruction: while b {
  e
}
Page: https://doc.rust-lang.org/book/ch03-05-control-flow.html
Effect: As long as b evaluate to true, evaluate e
Language: Rust
Chapter: 3
Variables: e: expression

Name: Ownership
Definition: A set of rule that allow program to know when to free memory
Page: https://doc.rust-lang.org/book/ch04-01-what-is-ownership.html
Chapter: 4
Context: Rust

Question: What is the constraint of data saved on the stack
Answer: Its size must be known at runtime
Page: https://doc.rust-lang.org/book/ch04-01-what-is-ownership.html
Chapter: 4
Context: Rust

Name: Pointer
Definition: Address of the location of some data
Page: https://doc.rust-lang.org/book/ch04-01-what-is-ownership.html
Chapter: 4
Context: Rust

Name: The owner of v
Definition: A variable such that v is dropped when the variable gets out of scope
Page: https://doc.rust-lang.org/book/ch04-01-what-is-ownership.html
Chapter: 4
Variables: v a value
Context: Rust
Cardinal: Exactly one

Meaning: A fixed unmutable string, known at compilation time
Page: https://doc.rust-lang.org/book/ch04-01-what-is-ownership.html
Language: Rust
Chapter: 4
Name: String literal

Instruction: String::from("foo")
Page: https://doc.rust-lang.org/book/ch04-01-what-is-ownership.html
Language: Rust
Chapter: 4
Returns: A String with content from literal foo

Instruction: v.drop()
Page: https://doc.rust-lang.org/book/ch04-01-what-is-ownership.html
Language: Rust
Chapter: 4
Returns: A function called when the owner of v becomes out of scope
Variables: v a value

Name: Double free error
Definition: The error of trying to free twice the same memory in the heap
Page: https://doc.rust-lang.org/book/ch04-01-what-is-ownership.html
Chapter: 4
Context: Rust

Instruction: v.clone()
Page: https://doc.rust-lang.org/book/ch04-01-what-is-ownership.html
Language: Rust
Chapter: 4
Returns: A new value similar to v
Variables: v value

Typ: &t
Meaning: A value of type t without ownership, that can't be modified
Page: https://doc.rust-lang.org/book/ch04-02-references-and-borrowing.html
Language: Rust
Chapter: 4
Variables: t a type
Name: A reference to a value of type t

Instruction: &v
Page: https://doc.rust-lang.org/book/ch04-02-references-and-borrowing.html
Language: Rust
Chapter: 4
Returns: A reference to the value of the variable v
Variables: v a variable
Name: Borrowing

Instruction: &mut v
Page: https://doc.rust-lang.org/book/ch04-02-references-and-borrowing.html
Language: Rust
Chapter: 4
Returns: A mutable reference to the value of the variable v
Variables: v a variable
Assuming: No other reference are borrowed in the scope of this variable

Name: Data race
Definition: Two or more pointers access the same data at the same time.
Page: https://doc.rust-lang.org/book/ch04-02-references-and-borrowing.html
Chapter: 4
Variables: t type
Definition2: At least one of the pointers is being used to write to the data.
Conjdef: The three conditions holds
Definition3: There’s no mechanism being used to synchronize access to the data.
Typ: &mut t

Name: Dangling reference
Definition: A reference to a data that has been dropped
Page: https://doc.rust-lang.org/book/ch04-02-references-and-borrowing.html
Chapter: 4

Instruction: iter.enumerate()
Page: https://doc.rust-lang.org/book/ch04-03-slices.html
Chapter: 4
Returns: An iterator returning pairs (i,elt_i) with elt_i the i-th element returned by the iterator
Variables: iter an iterator

Instruction: &s[i..j]
Page: https://doc.rust-lang.org/book/ch04-03-slices.html
Chapter: 4
Returns: The str object with letters between i (included) and j(excluded)'s letter
Variables: s a str
Assuming: Those are valid UTF-8 character boundaries
Name: string slice

Instruction: &ar[i..j]
Page: https://doc.rust-lang.org/book/ch04-03-slices.html
Chapter: 4
Returns: Reference to an array with elements of ar between i (included) and j(excluded)
Variables: ar: [t]
Name: slice

Instruction: struct Foo<T_1,...,T_m> {
  name_1: type_1,
  ...,
  name_n: type_n,
}
Page: https://doc.rust-lang.org/book/ch05-01-defining-structs.html
Meaning: Define a struct named foo with generic types T_i and variables name_i of type type_i.
Chapter: 5

Instruction: Foo {
  name_1: value_1,
  ...,
  name_n: value_n,
}
Page: https://doc.rust-lang.org/book/ch05-01-defining-structs.html
Effect: Evaluate each value_i
Chapter: 5
Returns: A structure Foo where variable name_i has value Value i
Variables: struct Foo {
  name_1: type_1,
  ...,
  name_n: type_n,
}
Abbreviation: Foo {
  value_1,
  ...,
  value_n,
}

Instruction: foo.name_i
Page: https://doc.rust-lang.org/book/ch05-01-defining-structs.html
Chapter: 5
Returns: The value associated with name_i in foo
Variables: struct Foo {
  name_1: type_1,
  ...,
  name_n: type_n,
}
foo: Foo

Instruction: Foo {
  name_i: value_i,
  name_i': value_i',
  ...foo
}
Page: https://doc.rust-lang.org/book/ch05-01-defining-structs.html
Chapter: 5
Returns: A copy of foo with name_i replaced by value_i
Variables: struct Foo {
  name_1: type_1,
  ...,
  name_n: type_n,
}
foo: Foo

Instruction: struct Name(
  t_1,
  ...,
  t_n
)
Page: https://doc.rust-lang.org/book/ch05-01-defining-structs.html
Meaning: Define a type Name with tuples t_1,
  ..., t_n
Chapter: 5

Instruction: Name(
  v_1,
  ...,
  v_n
)
Page: https://doc.rust-lang.org/book/ch05-01-defining-structs.html
Effect: Evaluate the v_i
Chapter: 5
Returns: Returning an object of type Name whose i-th value has value of v_i
Variables: struct Name(
  t_1,
  ..., t_n
)

Name: Unit-like struct
Definition: A structure without any field
Page: https://doc.rust-lang.org/book/ch05-01-defining-structs.html
Chapter: 5
Etymology: Isomorphic to the unit type

Name: A method
Definition: A function defined in the scope of a struct/trait/enum
Page: https://doc.rust-lang.org/book/ch05-03-method-syntax.html
Chapter: 5
Context: Rust

Instruction: impl<T_1,...,T_m> Foo {
   bar
}
Page: https://doc.rust-lang.org/book/ch05-03-method-syntax.html
Meaning: Indicate that bar implements the content of the structure Foo and self represents an element of type foo.
Methods m defined in bar can be called with elt.m with elt of type Foo
Language: Rust
Chapter: 5

Name: automatic referencing and dereferencing
Definition: Ensuring that referencing and dereferencing is used if required to call methods
Page: https://doc.rust-lang.org/book/ch05-03-method-syntax.html
Chapter: 5
Context: Rust

Name: Associated function
Definition: A function, defined in an impl and not using self
Page: https://doc.rust-lang.org/book/ch05-03-method-syntax.html
Chapter: 5
Context: Rust

Instruction: A::B
Page: https://doc.rust-lang.org/book/ch05-03-method-syntax.html
Language: Rust
Chapter: 5
Returns: Access to B associated to A
Variables: A a struct

Instruction: enum Foo<T_1,...,T_m> {
  e_1(t_11, ..., t_1m_1),
  ...,
  e_n(t_n1, ..., t_nm_n),
}
Page: https://doc.rust-lang.org/book/ch06-01-defining-an-enum.html
Meaning: Introduce an enumeration named Foo,
  with gerenircs T_i and variants being e_i with type (
  t_ii,
  ..., t_im_i
)
Language: Rust
Chapter: 6

Instruction: Foo::e_i v
Page: https://doc.rust-lang.org/book/ch06-01-defining-an-enum.html
Effect: Evaluates the v
Language: Rust
Chapter: 6
Returns: The e_i th value of the enum Foo, with parameters v
Variables: enum Foo {
  e_1 t_1,
  ...,
  e_n t_n,
}

Instruction: match f {
  Foo::e_1 v_1=> b_1,
  ...,
  Foo::e_n v_n=> b_n,
}
Page: https://doc.rust-lang.org/book/ch06-02-match.html
Language: Rust
Chapter: 6
Returns: If f is e_i then b_i where v_i is intepreted as the parameter of f
Variables: enum Foo {
  e_1 t_1,
  ...,
  e_n t_n,
}f: Foo

Name: An arm of a match
Definition: Some "Foo::e_i => v_i,"
Page: https://doc.rust-lang.org/book/ch06-02-match.html
Chapter: 6
Variables: enum Foo {
  e_1 t_1,
  ...,
  e_n t_n,
}
f: Foo
Context: Rust
match f {
  Foo::e_1 => v_1,
  ...,
  Foo::e_n => v_n,
}

Instruction: match f {
  Foo::e_1 v_1=> b_1,
  ...,
  Foo::e_n v_n=> b_n,
  _ => b
}
Page: https://doc.rust-lang.org/book/ch06-02-match.html
Language: Rust
Chapter: 6
Returns: If f is one of the e_i then b_i, otherwise b
Variables: enum Foo {
  e_1 t_1,
  ...,
  e_n t_n,
}
f: Foo

Instruction: if let e_i(v_i) = foo {bar}
Page: https://doc.rust-lang.org/book/ch06-02-match.html
Effect: If foo matches against e_i then exectue bar
Language: Rust
Chapter: 6
Variables: enum Foo {
  e_1 t_1,
  ...,
  e_n t_n,
}
f: Foo

Name: A collection
Definition: A data structure containing an arbitrary number of values
Page: https://doc.rust-lang.org/book/ch08-01-vectors.html
Chapter: 8
Context: Rust

Typ: Vec
Meaning: A container for a list with an arbitrary number of values
Page: https://doc.rust-lang.org/book/ch08-01-vectors.html
Language: Rust
Chapter: 8

Instruction: vec![foo_1, ..., foo_n]
Page: https://doc.rust-lang.org/book/ch08-01-vectors.html
Language: Rust
Chapter: 8
Returns: A vectors with ith element foo_i

Instruction: v.push(e)
Page: https://doc.rust-lang.org/book/ch08-01-vectors.html
Language: Rust
Chapter: 8
Returns: Add e at the end of v
Variables: v : Vec

Instruction: v.get(i)
Page: https://doc.rust-lang.org/book/ch08-01-vectors.html
Language: Rust
Chapter: 8
Returns: The i-th element with Some, or None
Variables: v : Vec
i int

Instruction: &v[i]
Page: https://doc.rust-lang.org/book/ch08-01-vectors.html
Language: Rust
Chapter: 8
Returns: Reference to the ith element
Variables: v : Vec
i int
Exception: Panick if i>= the lenth of v

Instruction: for i in &v {
  foo
}
Page: https://doc.rust-lang.org/book/ch08-01-vectors.html
Language: Rust
Chapter: 8
Returns: Execute foo, with i a reference for each element of v
Variables: v : Vec
i int

Instruction: for i in &mut v {
  foo
}
Page: https://doc.rust-lang.org/book/ch08-01-vectors.html
Language: Rust
Chapter: 8
Returns: Execute foo, with i a mutable reference for each element of v
Variables: v : Vec
i int

Instruction: s.chars()
Page: https://doc.rust-lang.org/book/ch08-01-vectors.html
Language: Rust
Chapter: 8
Returns: Iterator over the chars of s
Variables: s: String

Instruction: s.bytes()
Page: https://doc.rust-lang.org/book/ch08-01-vectors.html
Language: Rust
Chapter: 8
Returns: Iterator over the bytes of s
Variables: s: String

Typ: HashMap<K, V>
Meaning: Associating keys of type K to values of type V
Page: https://doc.rust-lang.org/book/ch08-01-vectors.html
Language: Rust
Chapter: 8

Instruction: m.insert(k, v)
Page: https://doc.rust-lang.org/book/ch08-01-vectors.html
Language: Rust
Chapter: 8
Returns: Associate key k to value v in map m
Variables: m: HashMap<K,V>

Instruction: m.get(k)
Page: https://doc.rust-lang.org/book/ch08-01-vectors.html
Language: Rust
Chapter: 8
Returns: Reference to the value associated to k if it exists, or Null
Variables: m: HashMap<K, V>

Instruction: m.entry(k).or_insert(v)
Page: https://doc.rust-lang.org/book/ch08-01-vectors.html
Effect: Associate k to v if it's absent
Language: Rust
Chapter: 8
Returns: A reference to the value associated to k
Variables: m: HashMap<K, V>

Question: What occurs when the program panic ?
Answer: Rust walk back and clean data from each level of the stack
Page: https://doc.rust-lang.org/book/ch09-01-unrecoverable-errors-with-panic.html
Chapter: 9
Context: Rust

Instruction: panic!(foo)
Page: https://doc.rust-lang.org/book/ch09-01-unrecoverable-errors-with-panic.html
Effect: Panic with message foo
Language: Rust
Chapter: 9

Name: Propagating the error
Definition: When a function receive an error, it returns its instead of the expected value to the caller
Page: https://doc.rust-lang.org/book/ch09-01-unrecoverable-errors-with-panic.html
Chapter: 9
Context: Rust

Name: Generic
Definition: abstract stand-ins for concrete types or other properties
Page: https://doc.rust-lang.org/book/ch10-00-generics.html
Chapter: 10
Context: Rust
Denoted by: Single letter upper cap

Name: Generic function
Definition: A function taking a generic parameter
Page: https://doc.rust-lang.org/book/ch10-00-generics.html
Chapter: 10
Context: Rust

Name: Lifetime
Definition: named regions of code that a reference must be valid for
Page: https://doc.rust-lang.org/book/ch10-00-generics.html
https://doc.rust-lang.org/nomicon/lifetimes.html
Chapter: 10
Context: Rust
Extra: A variety of generics that give the compiler information about how references relate to each other
Denoted by: Short lower cap name starting with '

Typ: [t]
Meaning: An array of element of type t with an aribtrary number of element
Page: https://doc.rust-lang.org/book/ch10-00-generics.html
Language: Rust
Chapter: 10

Name: Monomorphization
Definition: the process of turning generic code into specific code by filling in the concrete types that are used when compiled.
Page: https://doc.rust-lang.org/book/ch10-00-generics.html
Chapter: 10
Context: Rust

Question: What is the cost in using generic
Answer: No cost in time, only in executable size, thanks to Monomorphization
Page: https://doc.rust-lang.org/book/ch10-00-generics.html
Chapter: 10
Context: Rust

Instruction: pub trait Foo {
  fn bar_1(&self) -> t_1;
  ...
  fn bar_n(&self) -> t_n;
  fn plop_1(&self) -> t_1 {
    miam_1;
  }
  ...
  fn plop_m(&self) -> t_m {
    miam_m;
  }
}
Page: https://doc.rust-lang.org/book/ch10-02-traits.htmlb
Meaning: Define a trait. Each type defining that trait must have methods bar_i returning t_i and potentially plop_i, otherwise it'll have default miam_i
Language: Rust
Chapter: 10
Name: Trait
Intuition: Interface in some language

Instruction: impl Trait for T {
  fn bar_1(&self) -> t_1 {
    plop_1;
  }
  ...
  fn bar_n(&self) -> t_n {
    plop_n;
  }
}
Page: https://doc.rust-lang.org/book/ch10-02-traits.htmlb
Effect: State that T has Trait with the given implementation
Language: Rust
Chapter: 10
Assuming: Trait or type is local to the crate
Kind: T type
pub trait Trait {
  fn bar_1(&self) -> t_1;
  ...
  fn bar_n(&self) -> t_n;
}

Typ: (impl Trait_1 + ... + Trait_n)
Meaning: A type implementing all the Trait_i
Page: https://doc.rust-lang.org/book/ch10-02-traits.htmlb
Language: Rust
Chapter: 10

Instruction: T: Trait_1 + ... + Trait_n
Page: https://doc.rust-lang.org/book/ch10-02-traits.htmlb
Effect: Constraint the type T to be a generic for type implementing all the Trait_i
Language: Rust, Generic bound
Chapter: 10

Instruction: where T_1: Trait_1, ..., T_n: Trait_n after function type, before body
Page: https://doc.rust-lang.org/book/ch10-02-traits.html
Effect: Restrict generics types T_i to have trait Trait_i
Language: Rust, Generic bound
Chapter: 10

Typ: PartialOrd
Meaning: Trait for types implementing >, <, <= and >=
Page: https://doc.rust-lang.org/book/ch10-02-traits.html
Language: Rust
Chapter: 10

Typ: Copy
Meaning: Trait for types that can be copied
Page: https://doc.rust-lang.org/book/ch10-02-traits.html
Language: Rust
Chapter: 10

Typ: Display
Meaning: Trait for types that can be printed
Page: https://doc.rust-lang.org/book/ch10-02-traits.html
Language: Rust
Chapter: 10

Name: Blanket implementations
Definition: Implementing a trait for a type conditionnaly on the fact that it implements another trait
Page: https://doc.rust-lang.org/book/ch10-02-traits.html
Chapter: 10
Context: Rust
Example: ToString is a blanket implementation of Display. E.g. Each stirng that can be displayed automatically get access to to_string

Instruction: let x;
Page: https://doc.rust-lang.org/book/ch10-03-lifetime-syntax.html
Meaning: Open the scope of x without assigning a value
Language: Rust
Chapter: 10

Typ: &mut t
Page: https://doc.rust-lang.org/book/ch10-03-lifetime-syntax.html
Language: Rust
Chapter: 10
Variables: t a type
Name: A mutable reference to a value of type t

Typ: &'a mut t
Meaning: A mutable reference to a value of type t with lifetime 'a
Page: https://doc.rust-lang.org/book/ch10-03-lifetime-syntax.html
Language: Rust
Chapter: 10
Variables: t a type

Typ: &'a t
Meaning: A reference to a value of type t with lifetime 'a
Page: https://doc.rust-lang.org/book/ch10-03-lifetime-syntax.html
Language: Rust
Chapter: 10
Variables: t a type

Name: Input lifetime
Definition: Lifetimes on function or method parameters
Page: https://doc.rust-lang.org/book/ch10-03-lifetime-syntax.html
Chapter: 10
Context: Rust

Name: Output lifetime
Definition: Lifetimes on return values
Page: https://doc.rust-lang.org/book/ch10-03-lifetime-syntax.html
Chapter: 10
Context: Rust

Name: Lifetime elision rule
Definition: Each input and output lifetime are distinct
Page: https://doc.rust-lang.org/book/ch10-03-lifetime-syntax.html
Chapter: 10
Context: Rust
Definition2: There is a single input, and its lifetime is the output lifetime
Definition3: The output lifetime is the one of &self or &mut self
Intuition: A rule which let rust compiler figure out lifetime without indication

Instruction: omitted
Page: https://doc.rust-lang.org/book/ch10-03-lifetime-syntax.html
Effect: test
Language: Rust
Chapter: 10

Instruction: omitted
Page: https://doc.rust-lang.org/book/ch10-03-lifetime-syntax.html
Effect: I/O
Language: Rust
Chapter: 10

Instruction: |v_1, ..., v_n| {
  bar
}
Page: https://doc.rust-lang.org/book/ch10-03-lifetime-syntax.html
Language: Rust
Chapter: 10
Returns: A function taking n variables, executing and returning bar
Name: Closure

Question: Where are functions better than closure?
Answer: No overhead cost for saving its captures
Page: https://doc.rust-lang.org/book/ch10-03-lifetime-syntax.html
Chapter: 10
Context: Rust
Name: Closure

Function: fn next(&mut self) -> Option<Self::Item>;
Page: https://doc.rust-lang.org/book/ch13-02-iterators.html
Name: Iterator
Context: Rust
Chapter: 13
Variables: Item

Function: fn to_string(&mut self) -> str;
Page: https://doc.rust-lang.org/book/ch10-02-traits.html
Name: ToString
Context: Rust
Chapter: 10
Variables: Item

Name: A consuming adaptor
Definition: An adaptor that does not allow to use what it consumes after consumption
Page: https://doc.rust-lang.org/book/ch10-02-traits.html
Chapter: 10
Variables: a an iterable
Context: Rust
Example: sum consumes iterator. After the sum, iterator return None

Name: A smart pointer
Definition: A pointer implementing Deref and Drop
Page: https://doc.rust-lang.org/book/ch13-02-iterators.html
Chapter: 13

Function: fn drop(self);
Page: https://doc.rust-lang.org/book/ch13-02-iterators.html
Name: Drop
Chapter: 13

Instruction: v.deref()
Page: https://doc.rust-lang.org/book/ch15-01-box.html
Language: Rust
Chapter: 15
Variables: v: impl Deref
Abbreviation: *v

Name: Deref coercion
Definition: Applying .deref() as many time as required to an argument so that it gets the expected type
Page: https://doc.rust-lang.org/book/ch15-02-deref.html
Chapter: 15
Context: Rust

Question: In which order drops is called
Answer: Inverse order of variable creation
Page: https://doc.rust-lang.org/book/ch15-02-deref.html
Chapter: 15
Context: Rust

Instruction: std::mem::drop(v)
Page: https://doc.rust-lang.org/book/ch15-03-drop.html
Effect: Call v.drop()
Language: Rust
Chapter: 15

Name: RefCell
Definition: A reference to a value, checking borrowing rules at runtime instead of compile time
Page: https://doc.rust-lang.org/book/ch15-05-interior-mutability.html
Chapter: 15
Context: Rust

Instruction: r.borrow_mut()
Page: https://doc.rust-lang.org/book/ch15-05-interior-mutability.html
Language: Rust
Chapter: 15
Returns: A mutable reference to the value pointed by r
Variables: r a RefCell
Exception: Panic! if another borrow currently exists

Instruction: r.borrow()
Page: https://doc.rust-lang.org/book/ch15-05-interior-mutability.html
Language: Rust
Chapter: 15
Returns: A reference to the value pointed by r
Variables: r a RefCell
Exception: Panic! if a mutable borrow currently exists

Name: Green thread
Definition: A thread provided by a programming language, not necessarily provided by the Os
Page: https://doc.rust-lang.org/book/ch15-06-reference-cycles.html
Chapter: 15
Context: Rust

Name: Runtime
Definition: code that is included by the language in every binary
Page: https://doc.rust-lang.org/book/ch15-06-reference-cycles.html
Chapter: 15
Context: Rust

Instruction: thread::sleep(foo)
Page: https://doc.rust-lang.org/book/ch16-01-threads.html
Effect: Pause the thread for foo time
Language: Rust
Chapter: 16
Kind: foo Duration

Instruction: Duration::from_millis/second(n)
Page: https://doc.rust-lang.org/book/ch16-01-threads.html
Language: Rust
Chapter: 16
Returns: A representation for the duration of n millisecond/second
Kind: n integer

Instruction: thread::spawn(f)
Page: https://doc.rust-lang.org/book/ch16-01-threads.html
Effect: Start a new thread running f
Language: Rust
Chapter: 16
Returns: A handle to the new thread

Typ: JoinHandle
Meaning: Represents a thread
Page: https://doc.rust-lang.org/book/ch16-01-threads.html
Language: Rust
Chapter: 16

Instruction: j.join()
Page: https://doc.rust-lang.org/book/ch16-01-threads.html
Effect: Wait for the thread handled by j to halt
Language: Rust
Chapter: 16
Returns: Result
Kind: j: JoinHandle

Instruction: move |v_1, ..., v_n| {
  bar
}
Page: https://doc.rust-lang.org/book/ch16-01-threads.html
Effect: The variables are moved to the closure
Language: Rust
Chapter: 16
Returns: Same as |v_1, ..., v_n| {
  bar
}

Question: How do thread share data in rust ?
Answer: By passing messages
Page: https://doc.rust-lang.org/book/ch16-02-message-passing.html
Chapter: 16
Context: Rust

Name: A channel
Definition: A pair with an emetter and a receiver
Page: https://doc.rust-lang.org/book/ch16-02-message-passing.html
Chapter: 16
Context: Rust

Name: A closed channel
Definition: A channel whose transmetter or receiver is dropped
Page: https://doc.rust-lang.org/book/ch16-02-message-passing.html
Chapter: 16
Context: Rust

Name: multiple producer, single consumer
Page: https://doc.rust-lang.org/book/ch16-02-message-passing.html
Chapter: 16
Context: Rust
Typ: Thread
Etymology: MPSC

Instruction: mpsc::channel()
Page: https://doc.rust-lang.org/book/ch16-02-message-passing.html
Language: Rust
Chapter: 16
Returns: A pair with a transmitter and a receiver

Instruction: tx.send(val)
Page: https://doc.rust-lang.org/book/ch16-02-message-passing.html
Effect: Add val to the transmitter of tx
Language: Rust
Chapter: 16
Returns: Result
Variables: tx a transmitter

Instruction: rx.recv()
Page: https://doc.rust-lang.org/book/ch16-02-message-passing.html
Effect: Wait until rx's channel contain a message
Language: Rust
Chapter: 16
Returns: An element from rx's channel in a Result
Variables: rx a receiver

Instruction: rx.try_recv()
Page: https://doc.rust-lang.org/book/ch16-02-message-passing.html
Language: Rust
Chapter: 16
Returns: An element from rx's channel in a Result if there is one, Err otherwise
Variables: rx a receiver

Instruction: mpsc::Sender::clone(&tx)
Page: https://doc.rust-lang.org/book/ch16-02-message-passing.html
Language: Rust
Chapter: 16
Returns: A transmitter to tx's channel
Variables: tx a transmitter

Typ: Mutex<T>
Meaning: A value allowing to access a pointer to an element of type T at a single place of the program at a time
Page: https://doc.rust-lang.org/book/ch16-03-shared-state.html
Language: Rust
Chapter: 16

Instruction: m.lock()
Page: https://doc.rust-lang.org/book/ch16-03-shared-state.html
Effect: Wait for m to be unlocked. Lock m while the result is not dropped
Language: Rust
Chapter: 16
Returns: The value behind m in result
Variables: m: Mutex<T>

Typ: MutexGuard<T>
Meaning: A smartPointer to some value of type T behind a mutex
Page: https://doc.rust-lang.org/book/ch16-03-shared-state.html
Language: Rust
Chapter: 16

Instruction: pub (before a definition)
Page: https://doc.rust-lang.org/book/ch17-01-what-is-oo.html
Meaning: Indicate that the defined value can be accessed from anywhere
Language: Rust
Chapter: 17

Name: An object safe trait
Definition: return type is not self
Page: https://doc.rust-lang.org/book/ch17-01-what-is-oo.html
Chapter: 17
Context: Rust
Definition2: No generic type parameters
Conjdef: All methods satifies:
Etymology: A trait that can be used dynamically, as object

Typ: dyn T
Meaning: Represents an object of type T whose exact type is not known
Page: https://doc.rust-lang.org/book/ch17-01-what-is-oo.html
Language: Rust
Chapter: 17
Name: A dynamically sized type
Assuming: T is a object safe trait

Instruction: while let pat = iter {
  bar
}
Page: https://doc.rust-lang.org/book/ch18-01-all-the-places-for-patterns.html
Effect: Execute bar as long as iter matches against pattern pat
Language: Rust
Chapter: 18

Name: An irrefutable pattern
Definition: A pattern matching all avlues
Page: https://doc.rust-lang.org/book/ch18-01-all-the-places-for-patterns.html
Chapter: 18
Context: Rust
Example: A variable
Example2: _

Name: A pattern
Definition: Litteral
Page: https://doc.rust-lang.org/book/ch18-01-all-the-places-for-patterns.html
Chapter: 18
Context: Rust
Definition2: _
Conjdef: Either
Definition3: variable
Definition4: pattern | pattern
Definition5: struct
Definition6: tuple
Definition7: element of enum
Definition8: ..
Definition9: x..=y
Definition10: var @ pattern

Instruction: var @ pat
Page: https://doc.rust-lang.org/book/ch18-01-all-the-places-for-patterns.html
Effect: Match against pat and set the value to var
Language: Rust pattern
Chapter: 18

Instruction: _word
Page: https://doc.rust-lang.org/book/ch18-01-all-the-places-for-patterns.html
Effect: Match against anything and ignore the variable
Language: Rust pattern
Chapter: 18

Instruction: i..=j
Page: https://doc.rust-lang.org/book/ch18-01-all-the-places-for-patterns.html
Effect: Match against all constants between i and j
Language: Rust pattern
Chapter: 18

Instruction: pat|tern
Page: https://doc.rust-lang.org/book/ch18-03-pattern-syntax.html
Effect: Match against either pat or tern
Language: Rust pattern
Chapter: 18

Name: A package
Definition: 0 or 1 library
Page: https://doc.rust-lang.org/book/ch07-01-packages-and-crates.html
Chapter: 7
Context: Rust pattern
Definition2: An arbitrary number of binary

Name: Crate root
Definition: a source file that the Rust compiler starts from and makes up the root module of your crate
Page: https://doc.rust-lang.org/book/ch07-01-packages-and-crates.html
Chapter: 7
Context: Rust pattern

Name: Crate
Definition: A binary or a library
Page: https://doc.rust-lang.org/book/ch07-01-packages-and-crates.html
Chapter: 7
Context: Rust

Variable: main.rs
Meaning: The root of a binary crate
Page: https://doc.rust-lang.org/book/ch07-01-packages-and-crates.html
Language: Rust
Chapter: 7

Variable: lib.rs
Meaning: The root of a library crate
Page: https://doc.rust-lang.org/book/ch07-01-packages-and-crates.html
Language: Rust
Chapter: 7

Instruction: mod foo {
  bar
}
Page: https://doc.rust-lang.org/book/ch07-02-defining-modules-to-control-scope-and-privacy.html
Effect: bar gets defined in the module foo
Language: Rust
Chapter: 7

Instruction: self
Page: https://doc.rust-lang.org/book/ch07-02-defining-modules-to-control-scope-and-privacy.html
Language: Rust path
Chapter: 7
Returns: The current crate

Instruction: super
Page: https://doc.rust-lang.org/book/ch07-02-defining-modules-to-control-scope-and-privacy.html
Language: Rust path
Chapter: 7
Returns: The parent crate

Instruction: foo::bar
Page: https://doc.rust-lang.org/book/ch07-02-defining-modules-to-control-scope-and-privacy.html
Language: Rust path
Chapter: 7
Returns: The crate bar as a child of foo

Instruction: use path
Page: https://doc.rust-lang.org/book/ch07-04-bringing-paths-into-scope-with-the-use-keyword.html
Effect: Allow to use the coment of module path without using the prefix
Language: Rust
Chapter: 7

Instruction: use path as bar
Page: https://doc.rust-lang.org/book/ch07-04-bringing-paths-into-scope-with-the-use-keyword.html
Effect: Each path prefix bar is replaced by path
Language: Rust
Chapter: 7

Instruction: pub use foo
Page: https://doc.rust-lang.org/book/ch07-04-bringing-paths-into-scope-with-the-use-keyword.html
Effect: Same as `use foo` and foo is exported
Language: Rust
Chapter: 7

Instruction: use foo::{bar_1,...,bar_n}
Page: https://doc.rust-lang.org/book/ch07-04-bringing-paths-into-scope-with-the-use-keyword.html
Effect: Similar as
use foo::bar_1
...
use foo::bar_n
Language: Rust
Chapter: 7

Instruction: foo::*
Page: https://doc.rust-lang.org/book/ch07-04-bringing-paths-into-scope-with-the-use-keyword.html
Effect: All child on foo
Language: Rust path
Chapter: 7

Instruction: mod foo;
Page: https://doc.rust-lang.org/book/ch07-05-separating-modules-into-different-files.html
Effect: Load module foo from foo.rs
Language: Rust
Chapter: 7

Name: Release profile
Definition: predefined and customizable profiles with different configurations that allow a programmer to have more control over various options for compiling code
Page: https://doc.rust-lang.org/book/ch14-01-release-profiles.html
Chapter: 14
Context: Rust

Typ: 'static foo
Meaning: same as foo, but variable lifetime is the duration of the program
Page: https://doc.rust-lang.org/book/ch10-03-lifetime-syntax.html
Language: Rust
Chapter: 10

Typ: Self
Meaning: type I wrote at the top next to impl
Language: Rust

Question: What can be done only in Unsafe rust
Answer: Dereference a raw pointer
Page: https://doc.rust-lang.org/book/ch19-01-unsafe-rust.html
Chapter: 19
Context: Rust
Answer2: Call an unsafe function or method
Answer3: Access or modify a mutable static variable
Answer4: Implements an unsafe trait
Answer5: Access fields of `union`s

Question: How to use unsafe code
Answer: Encapsulate it into a safe abstraction that is the only interface user of your library knows
Page: https://doc.rust-lang.org/book/ch19-01-unsafe-rust.html
Chapter: 19
Context: Rust

Typ: *const T
Meaning: A pointer to a value of type T that can't be assigned to
Page: https://doc.rust-lang.org/book/ch19-01-unsafe-rust.html
Chapter: 19
Context: Rust

Typ: *mut T
Meaning: A pointer to a value of type T that can be assigned to
Page: https://doc.rust-lang.org/book/ch19-01-unsafe-rust.html
Chapter: 19
Context: Rust

Question: How does raw pointer differs from references
Answer: Are allowed to ignore the borrowing rules by having both immutable and mutable pointers or multiple mutable pointers to the same location
Page: https://doc.rust-lang.org/book/ch19-01-unsafe-rust.html
Chapter: 19
Context: Rust
Answer2: Aren’t guaranteed to point to valid memory
Answer3: Are allowed to be null
Answer4: Don’t implement any automatic cleanup

Question: How to create a raw pointer
Answer: Cast from a reference
Page: https://doc.rust-lang.org/book/ch19-01-unsafe-rust.html
Chapter: 19
Context: Rust

Instruction: unsafe fn name(args) {body}
Page: https://doc.rust-lang.org/book/ch19-01-unsafe-rust.html
Meaning: name can only be called in unsafe context
body is unsafe
Language: rust
Chapter: 19
Context: Rust
Similar to: fn name(args) {body}

Name: Application binary interface
Definition: Defines how to call the function at the assembly level
Page: https://doc.rust-lang.org/book/ch19-01-unsafe-rust.html
Chapter: 19
Context: Rust
Abbreviation: ABI

Instruction: extern "language" {
  decls
}
Page: https://doc.rust-lang.org/book/ch19-01-unsafe-rust.html
Meaning: Indicates that decls are function we can call, defined in language
Chapter: 19
Context: Rust

Question: Difference between immutable static variable and constant
Answer: constant may be duplicated by compiler. Static variable have a constant place in memory
Page: https://doc.rust-lang.org/book/ch19-01-unsafe-rust.html
Chapter: 19
Context: Rust

Typ: Add
Meaning: Type which can be added with +
Function: fun add(self, other: T) -> Self::Output
Page: https://doc.rust-lang.org/book/ch19-01-unsafe-rust.html
Context: Rust
Chapter: 19
Section: 2

Instruction: trait Name<Type=DefaultType> {
  decls
}
Page: https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
Meaning: If Type is not explicitly set, then its value is DefaultType
Language: Rust
Chapter: 19
Section: 2
Intuition: Usually DefaultType depends on Self or other explicitly stated type
Similar to: trait Name<Type> {
  decls
}

Instruction: Trait::method(&instance, args)
Page: https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
Effect: Same as instance.method(args), but ensure it uses the implementation of Trait
Language: Rust
Chapter: 19
Variables: Trait {
  fn method(params)
}
impl Trait for Class
instance: Class

Instruction: trait Name: superTrait {
  decls
}
Page: https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
Meaning: Require that this trait is implemented only on classes implementing superTrait
Language: Rust
Chapter: 19
Similar to: trait Name {
  decls
}

Typ: struct newType(oldType)
Meaning: oldType with a new name
Page: https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
Language: rust
Chapter: 19
Name: Newtype pattern
Etymology: Same definition in Haskell

Question: How to use Newtype pattern but allow to use old type methods without using .0
Answer: Newtype should implements the deref pattern
Page: https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
Chapter: 19
Context: rust
Name: Newtype pattern

Question: What are the uses of newtype pattern
Answer: ALlow to define trait you don't own on a type you don't own
Page: https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
Chapter: 19
Context: rust
Answer2: Allow to note semantical different. E.g. "Meter" is clearer than "u32"
Answer3: Hide internal implementation, e.g. naming HashMap<i32, String>

Question: When to prefer type aliases over newtype
Answer: When you just want to shorten a long type name
Page: https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
Chapter: 19
Context: rust

Instruction: type name = definition
Page: https://doc.rust-lang.org/book/ch19-04-advanced-types.html
Meaning: Create the syntacti sugar name for the type definition
Language: rust
Chapter: 19
Section: 4

Typ: fn(params_type) -> return_type
Meaning: The type of function taking params_type and returning return_type
Page: https://doc.rust-lang.org/book/ch19-05-advanced-functions-and-closures.html
Chapter: 19
Subtype of: Fn, FnMut, FnOnce

Question: When is it better to uses fn instead of Fn
Answer: To interface with c code, which does not have closure
Page: https://doc.rust-lang.org/book/ch19-05-advanced-functions-and-closures.html
Chapter: 19
Context: Rust

Question: The types of Macro in Rust
Answer: Declarative
Page: https://doc.rust-lang.org/book/ch19-06-macros.html
Chapter: 19
Context: Rust
Answer2: Procedural

Name: Procedural macro
Definition: Custom #[derive] macros
Page: https://doc.rust-lang.org/book/ch19-06-macros.html
Chapter: 19
Context: Rust
Definition2: Attribute-like macro
Definition3: Function-like macros

Name: Macro
Definition: Procedural macro
Page: https://doc.rust-lang.org/book/ch19-06-macros.html
Chapter: 19
Context: Rust
Definition2: Declarative macro
Conjdef: Any of

Name: Attribute-like macro
Definition: define custom attributes usable on any item
Page: https://doc.rust-lang.org/book/ch19-06-macros.html
Chapter: 19
Context: Rust

Name: Function-like macro
Definition: Macro that look like function calls but operate on the tokens specified as their argument
Page: https://doc.rust-lang.org/book/ch19-06-macros.html
Chapter: 19
Context: Rust

Name: Metaprogramming
Definition: Having code that writes code
Page: https://doc.rust-lang.org/book/ch19-06-macros.html
Chapter: 19
Context: Rust

Question: Constraint on macro
Answer: They must be defined in the file before being called
Page: https://doc.rust-lang.org/book/ch19-06-macros.html
Chapter: 19
Context: Rust

Instruction: #[macro_export]
Page: https://doc.rust-lang.org/book/ch19-06-macros.html
Effect: Exports the following macro when current crate is brought into scope
Context: Rust
Chapter: 19
Name: Declaration macro

Instruction: r#foo
Page: https://doc.rust-lang.org/book/appendix-01-keywords.html
https://doc.rust-lang.org/reference/identifiers.html
Effect: foo as a normal symbol instead of a reserved one
Context: Rust
Chapter: 21
Assuming: foo is not crate, self, super or Self
Name: raw identifier
Intuition: Interfacing with older rust or other language, with different reserved words