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
use crate::{FormattedContainer, FormattedParameter, Span};
use leo_grammar::console::FormattedString as GrammarFormattedString;
use serde::{Deserialize, Serialize};
use std::fmt;
#[derive(Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct FormattedString {
pub string: String,
pub containers: Vec<FormattedContainer>,
pub parameters: Vec<FormattedParameter>,
pub span: Span,
}
impl<'ast> From<GrammarFormattedString<'ast>> for FormattedString {
fn from(formatted: GrammarFormattedString<'ast>) -> Self {
let string = formatted.string;
let span = Span::from(formatted.span);
let containers = formatted.containers.into_iter().map(FormattedContainer::from).collect();
let parameters = formatted.parameters.into_iter().map(FormattedParameter::from).collect();
Self {
string,
containers,
parameters,
span,
}
}
}
impl fmt::Display for FormattedString {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.string)
}
}