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
use std::path::PathBuf;
use crate::{GPosIdx, WithPos};
#[derive(Clone, Debug, Default)]
pub struct PosString {
data: String,
span: GPosIdx,
}
impl From<String> for PosString {
fn from(data: String) -> PosString {
PosString {
data,
span: GPosIdx::UNKNOWN,
}
}
}
impl From<PosString> for String {
fn from(value: PosString) -> String {
value.data
}
}
impl From<PosString> for PathBuf {
fn from(value: PosString) -> Self {
value.data.into()
}
}
impl ToString for PosString {
fn to_string(&self) -> String {
self.data.to_string()
}
}
impl AsRef<str> for PosString {
fn as_ref(&self) -> &str {
&self.data
}
}
impl AsRef<std::path::Path> for PosString {
fn as_ref(&self) -> &std::path::Path {
self.data.as_ref()
}
}
impl WithPos for PosString {
fn copy_span(&self) -> GPosIdx {
self.span
}
}
impl PosString {
pub fn new(data: String, span: GPosIdx) -> Self {
Self { data, span }
}
pub fn with_span(mut self, span: GPosIdx) -> Self {
self.span = span;
self
}
}