Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. use std::boxed::Box;
  2.  
  3. struct Schema {
  4. test: bool,
  5. testfn: Box<Fn() -> String>,
  6. }
  7.  
  8. impl Schema {
  9. fn new<F: 'static>(test_in: F) -> Self
  10. where F: Fn() -> String
  11. {
  12. Schema{
  13. test: true,
  14. testfn: Box::new(test_in),
  15. }
  16. }
  17. }
  18.  
  19. fn test()->String {
  20. "test string".to_string()
  21. }
  22.  
  23. fn main() {
  24. let b = Box::new(5);
  25. println!("b = {}", b);
  26. println!("{}",test());
  27. let schema = Schema::new(test);
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement