mirror of
https://github.com/ahgamut/rust-ape-example.git
synced 2024-10-31 21:48:49 +00:00
36 lines
590 B
Rust
36 lines
590 B
Rust
|
// ./src/fn/closures/output_parameters.md
|
||
|
|
||
|
|
||
|
fn create_fn() -> impl Fn() {
|
||
|
let text = "Fn".to_owned();
|
||
|
|
||
|
move || println!("This is a: {}", text)
|
||
|
}
|
||
|
|
||
|
fn create_fnmut() -> impl FnMut() {
|
||
|
let text = "FnMut".to_owned();
|
||
|
|
||
|
move || println!("This is a: {}", text)
|
||
|
}
|
||
|
|
||
|
fn create_fnonce() -> impl FnOnce() {
|
||
|
let text = "FnOnce".to_owned();
|
||
|
|
||
|
move || println!("This is a: {}", text)
|
||
|
}
|
||
|
|
||
|
fn part0() {
|
||
|
let fn_plain = create_fn();
|
||
|
let mut fn_mut = create_fnmut();
|
||
|
let fn_once = create_fnonce();
|
||
|
|
||
|
fn_plain();
|
||
|
fn_mut();
|
||
|
fn_once();
|
||
|
}
|
||
|
|
||
|
pub fn main() {
|
||
|
part0();
|
||
|
}
|
||
|
|