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
use super::modifier::Modifier;
use crate::cons::Cons;
use crate::csharp::Csharp;
use crate::into_tokens::IntoTokens;
use crate::tokens::Tokens;
#[derive(Debug, Clone)]
pub struct Argument<'el> {
pub modifiers: Vec<Modifier>,
attributes: Tokens<'el, Csharp<'el>>,
ty: Csharp<'el>,
name: Cons<'el>,
}
impl<'el> Argument<'el> {
pub fn new<T, N>(ty: T, name: N) -> Argument<'el>
where
T: Into<Csharp<'el>>,
N: Into<Cons<'el>>,
{
Argument {
attributes: Tokens::new(),
modifiers: vec![],
ty: ty.into(),
name: name.into(),
}
}
pub fn attribute<T>(&mut self, attribute: T)
where
T: IntoTokens<'el, Csharp<'el>>,
{
self.attributes.push(attribute.into_tokens());
}
pub fn var(&self) -> Cons<'el> {
self.name.clone()
}
pub fn ty(&self) -> Csharp<'el> {
self.ty.clone()
}
}
into_tokens_impl_from!(Argument<'el>, Csharp<'el>);
impl<'el> IntoTokens<'el, Csharp<'el>> for Argument<'el> {
fn into_tokens(self) -> Tokens<'el, Csharp<'el>> {
let mut s = Tokens::new();
s.extend(self.attributes.into_iter());
s.extend(self.modifiers.into_tokens());
s.append(self.ty);
s.append(self.name);
s.join_spacing()
}
}