1 #[cfg(feature = "bytes")]
2 use bytes::Bytes;
3 
4 /// anything that can be cleared
5 pub trait Clear {
6     /// Clear this make, make it equivalent to newly created object.
clear(&mut self)7     fn clear(&mut self);
8 }
9 
10 impl<T> Clear for Option<T> {
clear(&mut self)11     fn clear(&mut self) {
12         self.take();
13     }
14 }
15 
16 impl Clear for String {
clear(&mut self)17     fn clear(&mut self) {
18         String::clear(self);
19     }
20 }
21 
22 impl<T> Clear for Vec<T> {
clear(&mut self)23     fn clear(&mut self) {
24         Vec::clear(self);
25     }
26 }
27 
28 #[cfg(feature = "bytes")]
29 impl Clear for Bytes {
clear(&mut self)30     fn clear(&mut self) {
31         Bytes::clear(self);
32     }
33 }
34