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
use std::borrow::Cow;
use serde::{Deserialize, Serialize};
#[derive(Debug, Eq, PartialEq, Serialize, Deserialize, Clone)]
pub struct RelateTo<'a> {
relates: Cow<'a, str>,
}
impl<'a> RelateTo<'a> {
#[must_use]
pub const fn new(relates: Cow<'a, str>) -> Self {
Self { relates }
}
#[must_use]
pub fn to(&self) -> &str {
&self.relates
}
}
impl<'a> From<&'a str> for RelateTo<'a> {
fn from(input: &'a str) -> Self {
RelateTo {
relates: Cow::Borrowed(input),
}
}
}
impl<'a> From<String> for RelateTo<'a> {
fn from(input: String) -> Self {
RelateTo {
relates: Cow::Owned(input),
}
}
}