1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
use Cow;
/// Trait for macros to convert owned/borrowed types to `Cow`.
///
/// This is needed because `&str` and `String` do not have `From`
/// implements into `Cow<_, [u8]>`. One solution is to just call `AsRef<[u8]>`
/// before converting. However, then when a user specifies an owned type,
/// we will implicitly borrow that; this trait prevents that so that macro
/// behavior is intuitive, so that owned types stay owned.
// TODO: Enable when specialization lands.
/*
impl<'a, T> BCowConvert<'a> for T where T: AsRef<[u8]> + 'a {
fn convert(self) -> Cow<'a, [u8]> {
self.into()
}
}*/