- i64 as i32
- usize as u64
- i32 as i64
- f64 as f32
str::thread::spawn(|| {
println!("LinkedIn");
});
- a closure
- a thread
- a future
- a block
- integer
- float
- boolean
- tuple
- Traits
- Tuples
- Enums
- Structs
- cargo --version
- cargo init
- cargo build
- cargo check
Q6. The term box and related phrases such as boxing a value are often used when relating to memory layout. What does box refer to?
- It's creating a pointer on the heap that points to a value on the stack.
- It's creating a pointer on the stack that points to a value on the heap.
- It's creating a memory guard around values to prevent illegal access.
- It's an abstraction that refers to ownership. "Boxed" values are clearly labelled.
...
let s = String::form("hello");
let slice = &s[0..2];
- let slice = &s[len + 2];
- let slice = &s[len - 2];
- let slice = &s.copy(0..2);
- let slice = &s[..2];
- a match pattern that branches into True or False
- calling ok_error()
- calling panic!()
- a match pattern that may result an early return
- Array::with_capacity(10)
- [i32]
- Array::new(10)
- [i32; 10]
Q10. What syntax is required to take a mutable reference to T, when used within a function argument?
fn increment(i: T) {
// body elided
}
- *mut T
- mut ref T
- mut &T
- &mut T
Q11. The smart pointers Rc and Arc provide reference counting. What is the API for incrementing a reference count?
-
.add()
-
.incr()
-
.clone()
-
.increment()
- The error is reported and execution continues.
- An exception is raised. The effect(s) of the exception are defined by the error! macro.
- The program panics immediately.
- Rust attempts to convert the error to the local function's error type and return it as Result::Err. If that fails, the program panics.
-
/*
-
#
-
//!
-
//
-
.ignore()
-
an underscore (_)
- ..
- skip
- function that ends the lifetime of one of its arguments
- struct that contains a reference to a value
- function with a generic argument
- struct that contains a reference to a boxed value