-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8676d7b
commit 4b99a70
Showing
33 changed files
with
126 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[package] | ||
name = "closures-anonymity" | ||
version = "0.1.0" | ||
authors = ["Aurélien DESBRIÈRES <[email protected]>"] | ||
|
||
[dependencies] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* Aurélien DESBRIÈRES | ||
aurelien(at)hackers(dot)camp | ||
License GNU GPL latest */ | ||
|
||
// Rust experimentations | ||
// Closures as Type Anonymity in Rust | ||
|
||
//`F` must implement `Fn` for a closure which takes no | ||
// inputs and returns nothing - exactly what is required | ||
// for `print`. | ||
fn apply<F>(f: F) where | ||
F: Fn() { | ||
f(); | ||
} | ||
|
||
fn main() { | ||
let x = 7; | ||
|
||
// Capture `x` into an anonymous type and implement | ||
// `Fn` for it. Sotre in `print`. | ||
let print = || println!("{}", x); | ||
|
||
apply(print); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
fn main() { | ||
println!("Hello, world!"); | ||
} |
Empty file.
1 change: 1 addition & 0 deletions
1
.../.fingerprint/closures-anonymity-6af39fbe3f7ef707/bin-closures_anonymity-6af39fbe3f7ef707
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
e5523b0cfc4c3222 |
1 change: 1 addition & 0 deletions
1
...gerprint/closures-anonymity-6af39fbe3f7ef707/bin-closures_anonymity-6af39fbe3f7ef707.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"rustc":7337822701906583572,"target":10252773731995063932,"profile":14528549471338536373,"local":{"variant":"MtimeBased","fields":[[1491495920,659360326],[47,104,111,109,101,47,97,117,114,101,108,105,101,110,47,103,105,116,47,114,117,115,116,47,99,108,111,115,117,114,101,115,45,97,110,111,110,121,109,105,116,121,47,116,97,114,103,101,116,47,100,101,98,117,103,47,46,102,105,110,103,101,114,112,114,105,110,116,47,99,108,111,115,117,114,101,115,45,97,110,111,110,121,109,105,116,121,45,54,97,102,51,57,102,98,101,51,102,55,101,102,55,48,55,47,100,101,112,45,98,105,110,45,99,108,111,115,117,114,101,115,95,97,110,111,110,121,109,105,116,121,45,54,97,102,51,57,102,98,101,51,102,55,101,102,55,48,55]]},"features":"None","deps":[],"rustflags":[]} |
Binary file added
BIN
+280 Bytes
...ngerprint/closures-anonymity-6af39fbe3f7ef707/dep-bin-closures_anonymity-6af39fbe3f7ef707
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/home/aurelien/git/rust/closures-anonymity/target/debug/closures-anonymity: /home/aurelien/git/rust/closures-anonymity/src/main.rs |
Binary file added
BIN
+3.39 MB
closures-anonymity/target/debug/deps/closures_anonymity-6af39fbe3f7ef707
Binary file not shown.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[package] | ||
name = "closures-as-output-parameters" | ||
version = "0.1.0" | ||
authors = ["Aurélien DESBRIÈRES <[email protected]>"] | ||
|
||
[dependencies] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* Aurélien DESBRIÈRES | ||
aurelien(at)hackers(dot)camp | ||
License GNU GPL latest */ | ||
|
||
// Rust experimentations | ||
// Closures as Output Parameters | ||
|
||
fn create_fn() -> Box<Fn()> { | ||
let text = "Fn".to_owned(); | ||
|
||
Box::new(move || println!("This is a: {}", text)) | ||
} | ||
|
||
fn create_fnmut() -> Box<FnMut()> { | ||
let text = "FnMut".to_owned(); | ||
|
||
Box::new(move || println!("This is al {}", text)) | ||
} | ||
|
||
fn main() { | ||
let fn_plain = create_fn(); | ||
let mut fn_mut = create_fnmut(); | ||
|
||
fn_plain(); | ||
fn_mut(); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
fn main() { | ||
println!("Hello, world!"); | ||
} |
Empty file.
1 change: 1 addition & 0 deletions
1
...-as-output-parameters-8be0a3943a8b9bac/bin-closures_as_output_parameters-8be0a3943a8b9bac
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
4b6a32595b0d8568 |
1 change: 1 addition & 0 deletions
1
...utput-parameters-8be0a3943a8b9bac/bin-closures_as_output_parameters-8be0a3943a8b9bac.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"rustc":7337822701906583572,"target":11229966374791113190,"profile":14528549471338536373,"local":{"variant":"MtimeBased","fields":[[1491497676,669321395],[47,104,111,109,101,47,97,117,114,101,108,105,101,110,47,103,105,116,47,114,117,115,116,47,99,108,111,115,117,114,101,115,45,97,115,45,111,117,116,112,117,116,45,112,97,114,97,109,101,116,101,114,115,47,116,97,114,103,101,116,47,100,101,98,117,103,47,46,102,105,110,103,101,114,112,114,105,110,116,47,99,108,111,115,117,114,101,115,45,97,115,45,111,117,116,112,117,116,45,112,97,114,97,109,101,116,101,114,115,45,56,98,101,48,97,51,57,52,51,97,56,98,57,98,97,99,47,100,101,112,45,98,105,110,45,99,108,111,115,117,114,101,115,95,97,115,95,111,117,116,112,117,116,95,112,97,114,97,109,101,116,101,114,115,45,56,98,101,48,97,51,57,52,51,97,56,98,57,98,97,99]]},"features":"None","deps":[],"rustflags":[]} |
Binary file added
BIN
+335 Bytes
...output-parameters-8be0a3943a8b9bac/dep-bin-closures_as_output_parameters-8be0a3943a8b9bac
Binary file not shown.
Binary file added
BIN
+3.4 MB
closures-as-output-parameters/target/debug/closures-as-output-parameters
Binary file not shown.
1 change: 1 addition & 0 deletions
1
closures-as-output-parameters/target/debug/closures-as-output-parameters.d
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/home/aurelien/git/rust/closures-as-output-parameters/target/debug/closures-as-output-parameters: /home/aurelien/git/rust/closures-as-output-parameters/src/main.rs |
Binary file added
BIN
+3.4 MB
...res-as-output-parameters/target/debug/deps/closures_as_output_parameters-8be0a3943a8b9bac
Binary file not shown.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[package] | ||
name = "closures-input-functions" | ||
version = "0.1.0" | ||
authors = ["Aurélien DESBRIÈRES <[email protected]>"] | ||
|
||
[dependencies] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* Aurélien DESBRIÈRES | ||
aurelien(at)hackers(dot)camp | ||
License GNU GPL latest */ | ||
|
||
// Rust experimentations | ||
// Closures as Input Functions | ||
|
||
// Define a function which takes a generic `F` argument | ||
// bounded by `Fn`, and calls it | ||
fn call_me<F: Fn()>(f: F) { | ||
f(); | ||
} | ||
|
||
// Define a wrapper function satisfying the `Fn` bounded | ||
fn function() { | ||
println!("I'm a function!"); | ||
} | ||
|
||
fn main() { | ||
// Define a closure satisfying the `Fn` bound | ||
let closure = || println!("I'm a closure!"); | ||
|
||
call_me(closure); | ||
call_me(function); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
fn main() { | ||
println!("Hello, world!"); | ||
} |
Empty file.
1 change: 1 addition & 0 deletions
1
...t/closures-input-functions-ca1b3e6e7180e373/bin-closures_input_functions-ca1b3e6e7180e373
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
59f07fec80106cb4 |
1 change: 1 addition & 0 deletions
1
...sures-input-functions-ca1b3e6e7180e373/bin-closures_input_functions-ca1b3e6e7180e373.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"rustc":7337822701906583572,"target":17611836378413514346,"profile":14528549471338536373,"local":{"variant":"MtimeBased","fields":[[1491496483,209347855],[47,104,111,109,101,47,97,117,114,101,108,105,101,110,47,103,105,116,47,114,117,115,116,47,99,108,111,115,117,114,101,115,45,105,110,112,117,116,45,102,117,110,99,116,105,111,110,115,47,116,97,114,103,101,116,47,100,101,98,117,103,47,46,102,105,110,103,101,114,112,114,105,110,116,47,99,108,111,115,117,114,101,115,45,105,110,112,117,116,45,102,117,110,99,116,105,111,110,115,45,99,97,49,98,51,101,54,101,55,49,56,48,101,51,55,51,47,100,101,112,45,98,105,110,45,99,108,111,115,117,114,101,115,95,105,110,112,117,116,95,102,117,110,99,116,105,111,110,115,45,99,97,49,98,51,101,54,101,55,49,56,48,101,51,55,51]]},"features":"None","deps":[],"rustflags":[]} |
Binary file added
BIN
+310 Bytes
...osures-input-functions-ca1b3e6e7180e373/dep-bin-closures_input_functions-ca1b3e6e7180e373
Binary file not shown.
Binary file not shown.
1 change: 1 addition & 0 deletions
1
closures-input-functions/target/debug/closures-input-functions.d
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/home/aurelien/git/rust/closures-input-functions/target/debug/closures-input-functions: /home/aurelien/git/rust/closures-input-functions/src/main.rs |
Binary file added
BIN
+3.39 MB
closures-input-functions/target/debug/deps/closures_input_functions-ca1b3e6e7180e373
Binary file not shown.