Title: Theory / Unimportant / CS / Programming / Rust / Library / Result
Tags: automatedNewLineAfterCommaSpace computer_to_instruction

Typ: Result<T, E>
Page: https://doc.rust-lang.org/book/ch00-00-introduction.html
Language: Rust
Chapter: 0
Value: Ok (with some value of type T)
Value2: Err (with some value of type E)

Instruction: result.expect(foo)
Page: https://doc.rust-lang.org/book/ch00-00-introduction.html
Effect: Dies if the result is not ok and print foo
Language: Rust
Chapter: 0
Returns: The value contained by result, if Ok
Variables: Result result

Question: What occurs when the code contains a value of type Result
Answer: It must be checked with expect or it leads to a warning
Page: https://doc.rust-lang.org/book/ch00-00-introduction.html
Chapter: 0
Context: Rust

Name: Expressions
Definition: instructions that evaluate to a resulting value
Page: https://doc.rust-lang.org/book/ch03-01-variables-and-mutability.html
Chapter: 3
Context: Rust
Example: Literals
Example2: A block of statements followed by an expression

Instruction: r.unwrap()
Page: https://doc.rust-lang.org/book/ch09-01-unrecoverable-errors-with-panic.html
Effect: Panic if r is an error
Language: Rust
Chapter: 9
Returns: The OK value of r
Variables: r : Result<T, E>

Instruction: r.expect(foo)
Page: https://doc.rust-lang.org/book/ch09-01-unrecoverable-errors-with-panic.html
Effect: Panic with message foo if r is an error
Language: Rust
Chapter: 9
Returns: The OK value of r
Variables: r : Result<T, E>

Instruction: r?
Page: https://doc.rust-lang.org/book/ch09-01-unrecoverable-errors-with-panic.html
Effect: the function return r if it's Err (potentially applying "from" to transform to correct type)
Language: Rust
Chapter: 9
Returns: The value of r if it's okay
Variables: r : Result<T, E>

Question: What to do if a computation goes wrong in a way that can be reasonably be handled
Answer: Result
Page: https://doc.rust-lang.org/nomicon/unwinding.html
Context: Rust

Instruction: result.is_ok()
Page: https://doc.rust-lang.org/stable/std/result/index.html
Returns: Whether result is ok
Variables: result: Result<T, E>

Instruction: result.is_err()
Page: https://doc.rust-lang.org/stable/std/result/index.html
Returns: Whether result is err
Variables: result: Result<T, E>

Instruction: result.as_ref()
Page: https://doc.rust-lang.org/stable/std/result/index.html
Returns: Result is not a reference, but contains reference to its value: Result<&T, &E>
Variables: result: &Result<T, E>

Instruction: result.as_mut()
Page: https://doc.rust-lang.org/stable/std/result/index.html
Returns: Result is not a reference, but contains reference to its value: Result<&mut T, &mut E>
Variables: result: &mut Result<T, E>

Instruction: result.as_deref(_mut)()
Page: https://doc.rust-lang.org/stable/std/result/index.html
Returns: Same result, with ok dereferenced if possible: &Result<&(|mut )T::Target, &E>
Variables: result: &Result<T, E>

Instruction: result.ok()
Page: https://doc.rust-lang.org/stable/std/result/index.html
Returns: Option to the okay value
Variables: result: Result<T, E>

Instruction: result.err()
Page: https://doc.rust-lang.org/stable/std/result/index.html
Returns: Option to the error value
Variables: result: Result<T, E>

Instruction: result.map(fn)
result.and_then(fn)
Page: https://doc.rust-lang.org/stable/std/result/index.html
Returns: result with fn(ok_value) or same error
Variables: result: Result<T, E>

Instruction: result.map_or(fn)
Page: https://doc.rust-lang.org/stable/std/result/index.html
Returns: okay value or fn(error)
Variables: result: Result<T, E>

Instruction: result.map_or_else(
  err_fn,
  ok_fn
)
Page: https://doc.rust-lang.org/stable/std/result/index.html
Returns: result of err_fn or ok_fn to the contained value
Variables: result: Result<T,
  E>

Instruction: result.map_err(fn)
Page: https://doc.rust-lang.org/stable/std/result/index.html
Returns: map, applying fn to error
Variables: result: Result<T, E>

Instruction: result.iter(|_mut)()
Page: https://doc.rust-lang.org/stable/std/result/index.html
Returns: iterator (mutable) with single okay value or nothing
Variables: result: Result<T, E>

Instruction: result.unwrap_or_default()
Page: https://doc.rust-lang.org/stable/std/result/index.html
Returns: the okay value or T::default
Variables: result: Result<T, E>

Instruction: result.expect_err(panic_msg)
Page: https://doc.rust-lang.org/stable/std/result/index.html
Effect: panic with panic_msg if not an error
Returns: The error
Variables: result: Result<T, E>

Instruction: result.unwrap_err()
Page: https://doc.rust-lang.org/stable/std/result/index.html
Effect: panic if result is ok
Returns: The error
Variables: result: Result<T, E>

Instruction: result.or(other_result)
Page: https://doc.rust-lang.org/stable/std/result/index.html
Returns: result if okay, other_result otherwise
Variables: result: Result<T, E>

Instruction: result.or_else(err_fn)
Page: https://doc.rust-lang.org/stable/std/result/index.html
Returns: result if okay, fn(err) otherwise
Variables: result: Result<T, E>

Instruction: result.unwrap_or(default)
Page: https://doc.rust-lang.org/stable/std/result/index.html
Returns: result if okay, default otherwise
Variables: result: Result<T, E>

Instruction: result.unwrap_or_else(err_fn)
Page: https://doc.rust-lang.org/stable/std/result/index.html
Returns: result if okay, err_fn(error) otherwise: T
Variables: result: Result<T, E>

Instruction: result.unwrap_unchecked()
Page: https://doc.rust-lang.org/stable/std/result/index.html
Returns: The okay value, consumes it
Variables: result: Result<T, E>

Instruction: result.unwrap_err_unchecked()
Page: https://doc.rust-lang.org/stable/std/result/index.html
Returns: The err value, consumes it
Variables: result: Result<T, E>

Instruction: result todo remaining
Page: https://doc.rust-lang.org/stable/std/result/index.html
Returns: The err value, consumes it
Variables: result: Result<T, E>