Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct Foo {
- some_data: i32,
- }
- impl Foo {
- fn some_func(&self) {
- println!("{}", self.some_data)
- }
- fn run<T, F>(&self, data: &T, func: F)
- where F: Fn(&T) + 'static
- {
- func(data);
- }
- fn exec(&self) {
- self.run(self, &Foo::some_func);
- }
- }
- fn main() {
- let foo = Foo { some_data: 0x666 };
- foo.exec();
- }
Add Comment
Please, Sign In to add comment