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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
use std::marker::PhantomData;
use std::ops::Deref;
use crate::*;
#[derive(Debug, Copy, Clone)]
pub struct StrSliceRef<'a> {
string: &'a str,
referent: PhantomData<&'a mut u8>,
}
impl<'a> StrSliceRef<'a> {
#[inline]
pub fn new<T>(_src: &'a mut T, string: &'a str) -> Self {
StrSliceRef {
string,
referent: PhantomData::default(),
}
}
#[inline]
pub fn as_str(&self) -> &str {
self.string
}
}
impl Deref for StrSliceRef<'_> {
type Target = str;
#[inline]
fn deref(&self) -> &Self::Target {
self.string
}
}
impl AsRef<str> for StrSliceRef<'_> {
fn as_ref(&self) -> &str {
self.string
}
}
#[derive(Debug, Clone)]
pub struct StrSlicesRef<'a> {
strs: Vec<&'a str>,
referent: PhantomData<&'a mut u8>,
}
impl<'a> StrSlicesRef<'a> {
#[inline]
pub fn new<T>(_src: &'a mut T, strs: Vec<&'a str>) -> Self {
Self {
strs,
referent: Default::default(),
}
}
#[inline]
pub fn as_slice(&self) -> &[&str] {
self.strs.as_slice()
}
}
impl<'a> Deref for StrSlicesRef<'a> {
type Target = [&'a str];
#[inline]
fn deref(&self) -> &Self::Target {
&self.strs.as_slice()
}
}
impl<'a> AsRef<[&'a str]> for StrSlicesRef<'a> {
fn as_ref(&self) -> &[&'a str] {
self.strs.as_slice()
}
}