Created
February 27, 2018 20:00
-
-
Save pjhades/c71995718c15d385cf507adae9aa88e3 to your computer and use it in GitHub Desktop.
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
struct S; | |
impl S { | |
fn foo(&self) { println!("S::foo"); } | |
fn bar(&self) { println!("S::bar"); } | |
} | |
fn foo() { println!("foo"); } | |
fn bar() { println!("bar"); } | |
fn main() { | |
let fps: [fn();2] = [foo, bar]; | |
for f in fps.iter() { | |
f(); | |
} | |
println!("sizeof={}", std::mem::size_of_val(&fps)); | |
let s = S {}; | |
let fps: [&Fn(&S);2] = [&S::foo, &S::bar]; | |
for f in fps.iter() { | |
f(&s); | |
} | |
println!("sizeof={}", std::mem::size_of_val(&fps)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment