Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use std::boxed::Box;
- struct Schema {
- test: bool,
- testfn: Box<Fn() -> String>,
- }
- impl Schema {
- fn new<F: 'static>(test_in: F) -> Self
- where F: Fn() -> String
- {
- Schema{
- test: true,
- testfn: Box::new(test_in),
- }
- }
- }
- fn test()->String {
- "test string".to_string()
- }
- fn main() {
- let b = Box::new(5);
- println!("b = {}", b);
- println!("{}",test());
- let schema = Schema::new(test);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement