January 2018
Beginner to intermediate
454 pages
10h 8m
English
The argument of this method is somewhat special:
|application| { let window = ApplicationWindow::new(&application); window.set_title("Rusic"); window.show(); }
This is what we call a closure. A closure is a concise way of declaring a function that does not have a name and can capture the environment. Capturing the environment means that it can access the variables from outside the closure, something which is not possible to do with normal functions. The methods to connect a signal will run the function (in this case, a closure) passed as an argument. Here, create the window.
We could have decided to create a normal function, as the following code does:
fn startup_handler(application: &Application) { let window = ApplicationWindow::new(&application); ...
Read now
Unlock full access