mocktopus_macros 0.1.2

Mocktopus procedural macros
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use std::fmt::{Display, Error, Formatter};

pub struct DisplayDelegate<T: Fn (&mut Formatter) -> Result<(), Error>> {
    delegate: T,
}

impl <T: Fn(&mut Formatter) -> Result<(), Error>> DisplayDelegate<T> {
    pub fn new(delegate: T) -> Self {
        DisplayDelegate { delegate }
    }
}

impl <T: Fn(&mut Formatter) -> Result<(), Error>> Display for DisplayDelegate<T> {
    fn fmt(&self, formatter: &mut Formatter) -> Result<(), Error> {
        (self.delegate)(formatter)
    }
}