+3 -25 +/-2 browse
1 | diff --git a/benches/parse.rs b/benches/parse.rs |
2 | index d5a0721..be94266 100644 |
3 | --- a/benches/parse.rs |
4 | +++ b/benches/parse.rs |
5 | @@ -2,7 +2,6 @@ |
6 | //extern crate melib; |
7 | // |
8 | //use melib::mailbox::backends::maildir::MaildirOp; |
9 | - //use melib::mailbox::backends::BackendOpGenerator; |
10 | //use melib::mailbox::email::Envelope; |
11 | // |
12 | //extern crate test; |
13 | diff --git a/melib/src/backends.rs b/melib/src/backends.rs |
14 | index a8b7921..75d8024 100644 |
15 | --- a/melib/src/backends.rs |
16 | +++ b/melib/src/backends.rs |
17 | @@ -155,7 +155,7 @@ pub trait MailBackend: ::std::fmt::Debug { |
18 | } |
19 | |
20 | /// A `BackendOp` manages common operations for the various mail backends. They only live for the |
21 | - /// duration of the operation. They are generated by `BackendOpGenerator` on demand. |
22 | + /// duration of the operation. They are generated by the `operation` method of `Mailbackend` trait. |
23 | /// |
24 | /// # Motivation |
25 | /// |
26 | @@ -171,7 +171,7 @@ pub trait MailBackend: ::std::fmt::Debug { |
27 | /// |
28 | /// # Example |
29 | /// ``` |
30 | - /// use melib::mailbox::backends::{BackendOp, BackendOpGenerator}; |
31 | + /// use melib::mailbox::backends::{BackendOp}; |
32 | /// use melib::Result; |
33 | /// use melib::{Envelope, Flag}; |
34 | /// |
35 | @@ -196,8 +196,7 @@ pub trait MailBackend: ::std::fmt::Debug { |
36 | /// } |
37 | /// } |
38 | /// |
39 | - /// let foogen = BackendOpGenerator::new(Box::new(|| Box::new(FooOp {}))); |
40 | - /// let operation = foogen.generate(); |
41 | + /// let operation = Box::new(FooOp {}); |
42 | /// assert_eq!("Foobar", &operation.description()); |
43 | /// ``` |
44 | pub trait BackendOp: ::std::fmt::Debug + ::std::marker::Send { |
45 | @@ -211,26 +210,6 @@ pub trait BackendOp: ::std::fmt::Debug + ::std::marker::Send { |
46 | fn set_flag(&mut self, envelope: &mut Envelope, flag: Flag) -> Result<()>; |
47 | } |
48 | |
49 | - /// `BackendOpGenerator` is a wrapper for a closure that returns a `BackendOp` object |
50 | - /// See `BackendOp` for details. |
51 | - /* |
52 | - * I know this sucks, but that's the best way I found that rustc deems safe. |
53 | - * */ |
54 | - pub struct BackendOpGenerator(Box<Fn() -> Box<BackendOp>>); |
55 | - impl BackendOpGenerator { |
56 | - pub fn new(b: Box<Fn() -> Box<BackendOp>>) -> Self { |
57 | - BackendOpGenerator(b) |
58 | - } |
59 | - pub fn generate(&self) -> Box<BackendOp> { |
60 | - self.0() |
61 | - } |
62 | - } |
63 | - unsafe impl Send for BackendOpGenerator {} |
64 | - unsafe impl Sync for BackendOpGenerator {} |
65 | - impl fmt::Debug for BackendOpGenerator { |
66 | - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { |
67 | - let op = self.generate(); |
68 | - write!(f, "BackendOpGenerator: {}", op.description()) |
69 | } |
70 | } |
71 |