Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct Stuc {
- id: usize,
- }
- impl Stuc {
- fn fun(self) -> Box<Fn()> {
- Box::new(move ||{
- println!("id={}", self.id);
- })
- }
- }
- fn main() {
- let stuc = Stuc { id: 5 };
- let fun = stuc.fun();
- fun();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement