1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
use std::borrow::Cow;
#[derive(Debug, Clone, Default)]
pub struct Device<'a> {
pub name: Option<Cow<'a, str>>,
pub brand: Option<Cow<'a, str>>,
pub model: Option<Cow<'a, str>>,
}
impl<'a> Device<'a> {
#[inline]
pub fn into_owned(self) -> Device<'static> {
let device = self.name.map(|c| Cow::from(c.into_owned()));
let brand = self.brand.map(|c| Cow::from(c.into_owned()));
let model = self.model.map(|c| Cow::from(c.into_owned()));
Device {
name: device,
brand,
model,
}
}
}