Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct Schema<F>
- where
- F: Fn() -> String
- {
- f: F,
- }
- impl<F> Schema<F>
- where
- F: Fn() -> String
- {
- fn new(f: F) -> Self {
- Schema { f }
- }
- fn test(&self) {
- println!("{}", (self.f)())
- }
- }
- fn test() -> String {
- "test string".to_string()
- }
- fn range(r: std::ops::Range<usize>) -> impl Fn() -> String {
- move || -> String { format!("range() min:{} max:{}", r.start, r.end) }
- }
- fn main() {
- let schema = Schema::new(test);
- schema.test();
- let schema = Schema::new(range(1 .. 65000));
- schema.test();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement