In the following code snippet:
let read_pool = ReadPool::new(
"readpool",
&Config::default_for_test(),
|| || Context {}
);
What are the four vertical lines || ||
?
Characteristics of Lines Vertical lines are seen as tall and represent grandeur. Horizontal and vertical lines used together in a square or rectangular shape convey structure and represent stability.
The vertical line in the given graph is called Y-axis. In the Cartesian coordinate system, the vertical reference line is called Y-axis. Was this answer helpful?
The vertical line or bar , |, between a and b is called the pipe. The notation a ∣ b \color{red}{a|b} a∣b is read as “ a divides b“.
The vertical bar is used as a mathematical symbol in numerous ways: absolute value: , read "the absolute value of x" cardinality: , read "the cardinality of the set S" conditional probability: , reads "the probability of X given Y" determinant: , read "the determinant of the matrix A".
||
represents a lambda taking no arguments.
fn main() {
let a = || println!("hello");
let b = || { println!("world") };
a(); // hello
b(); // world
}
Two together is a lambda returning another lambda:
fn main() {
let a = || || println!("hello world");
let c = a();
c(); // hello world
}
In Rust, ||
introduces a lambda (an unnamed function).
The arguments of the lambda are specified in between the two:
|a, b| a + b
: a lambda taking 2 arguments a
and b
and returning their sum,|| println!("Hello, World")
: a lambda taking no argument and printing "Hello, World!".Since the body of a lambda is just an expression, it can be another lambda:
|| || println!("Hello, World")
: a lambda taking no argument and returning a lambda taking no argument and printing "Hello, World!".Therefore, || || Context {}
is simply:
|| Context {}
,Context
.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With