Debian Codegraph @

src/sexp.rs

raw symbols SCIP
1 // (c) 2016-2017 Productize SPRL <[email protected]>
2
3 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/;
4 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/;
5
6 use error::SexpError;
7 /// like Into trait but works from a ref avoiding consumption or expensive clone
8 pub trait IntoSexprust-analyzer cargo symbolic_expressions 5.0.3 sexp/IntoSexp# {
9 /// convert self into a Sexp
10 fn into_sexprust-analyzer cargo symbolic_expressions 5.0.3 sexp/IntoSexp#into_sexp().(&self) -> Sexprust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp#;
11 }
12
13 impl Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<Sexprust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp#> for Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Sexprust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp#> {
14 fn intorust-analyzer cargo symbolic_expressions 5.0.3 sexp/impl#[`Vec<Sexp>`][`Into<Sexp>`]into().(self: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Sexprust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp#>) -> Sexprust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp# {
15 Sexprust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp#::Listrust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp#List#(self)
16 }
17 }
18
19 impl Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<Sexprust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp#> for Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# {
20 fn intorust-analyzer cargo symbolic_expressions 5.0.3 sexp/impl#[String][`Into<Sexp>`]into().(self: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#) -> Sexprust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp# {
21 Sexprust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp#::Stringrust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp#String#(self)
22 }
23 }
24
25 impl<'a> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<&'a str> for Sexprust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp# {
26 fn fromrust-analyzer cargo symbolic_expressions 5.0.3 sexp/impl#[Sexp][`From<&'a str>`]from().(t: &str) -> Sexprust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp# {
27 Sexprust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp#::Stringrust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp#String#(t.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().())
28 }
29 }
30
31 impl<'a> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<&'a Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> for Sexprust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp# {
32 fn fromrust-analyzer cargo symbolic_expressions 5.0.3 sexp/impl#[Sexp][`From<&'a String>`]from().(t: &Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#) -> Sexprust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp# {
33 Sexprust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp#::Stringrust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp#String#(t.clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][Clone]clone().())
34 }
35 }
36
37 impl Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<Sexprust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp#> for i64 {
38 fn intorust-analyzer cargo symbolic_expressions 5.0.3 sexp/impl#[i64][`Into<Sexp>`]into().(self: i64) -> Sexprust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp# {
39 Sexprust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp#::Stringrust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp#String#(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{}", self))
40 }
41 }
42
43 impl Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<Sexprust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp#> for f64 {
44 fn intorust-analyzer cargo symbolic_expressions 5.0.3 sexp/impl#[f64][`Into<Sexp>`]into().(self: f64) -> Sexprust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp# {
45 Sexprust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp#::Stringrust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp#String#(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{}", self))
46 }
47 }
48
49 impl<'a> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<(&'a str, Sexprust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp#)> for Sexprust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp# {
50 fn fromrust-analyzer cargo symbolic_expressions 5.0.3 sexp/impl#[Sexp][`From<(&'a str, Sexp)>`]from().(kv: (&str, Sexprust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp#)) -> Sexprust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp# {
51 let (name, value) = kv;
52 let mut v = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![];
53 v.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(name.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
54 v.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(value);
55 v.intorust-analyzer cargo symbolic_expressions 5.0.3 sexp/impl#[`Vec<Sexp>`][`Into<Sexp>`]into().()
56 }
57 }
58
59 impl<'a, T: fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display#> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<(&'a str, &'a T)> for Sexprust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp# {
60 fn fromrust-analyzer cargo symbolic_expressions 5.0.3 sexp/impl#[Sexp][`From<(&'a str, &'a T)>`]from().(kv: (&str, &T)) -> Sexprust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp# {
61 let (name, value) = kv;
62 let mut v = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![];
63 v.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(name.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
64 v.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{}", value).intorust-analyzer cargo symbolic_expressions 5.0.3 sexp/impl#[String][`Into<Sexp>`]into().());
65 v.intorust-analyzer cargo symbolic_expressions 5.0.3 sexp/impl#[`Vec<Sexp>`][`Into<Sexp>`]into().()
66 }
67 }
68
69 /// a symbolic-expression structure
70 /// Can be a string or a list or nothing
71 ///
72 /// `String` shape: hello
73 /// `List` shape: (...)
74 /// `Empty shape:
75 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:)]
76 pub enum Sexprust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp# {
77 /// plain String symbolic-expression
78 Stringrust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp#String#(Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#),
79 /// list symbolic-expression
80 Listrust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp#List#(Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Sexprust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp#>),
81 /// empty, trivial symbolic-expression
82 Emptyrust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp#Empty#,
83 }
84
85 // Following the KiCad file formats specification chapter 4.4 - Identifiers and Strings:
86 // A string may not contain an actual newline or carriage return,
87 // but it may use an escape sequence to encode a // newline, such as \n.
88 // If a string has any of the following conditions, then it must be quoted
89 // with a leading and trailing double quote
90 // character, otherwise it is acceptable to not quote the string:
91 // 1. has one or more of the following 4 separator bytes: ASCII space,
92 // tab, '(', or ')'.
93 // 2. has one or more of the following bytes: '%', '{', or '}'.
94 // 3. has a length of zero bytes, and you need a place holder for the field,
95 // then use "".
96 // 4. includes a byte of '-', and this byte is not in the first position of
97 // the string.
98 //
99
100 // Joost remark: kicad no longer seems to follow Rule 4.
101 // so we don't either
102
103 /// encode a string according to the guidelines given by Kicad
104 pub fn encode_stringrust-analyzer cargo symbolic_expressions 5.0.3 sexp/encode_string().(s: &str) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# {
105 // fn rule_4(s:&str) -> bool {
106 // s.contains('-') && s.len() > 1 && s.as_bytes()[0] != 45
107 // }
108 if s.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]contains().('(') || s.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]contains().(' ') || s.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]contains().(')') || s.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]contains().('\t') || s.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]contains().('{')
109 || s.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]contains().('}') || s.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]contains().('}') || s.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]contains().('%') || s.is_emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]is_empty().()
110 // || rule_4(s)
111 {
112 formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("\"{}\"", s)
113 } else {
114 Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::fromrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`From<&str>`]from().(s)
115 }
116 }
117
118 impl Sexprust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp# {
119 /// create an empty symbolic-expression
120 #[deprecated(since = "4.0.0", note = "please use `Sexp::default()` instead")]
121 pub fn new_emptyrust-analyzer cargo symbolic_expressions 5.0.3 sexp/impl#[Sexp]new_empty().() -> Sexprust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp# {
122 Sexprust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp#::Emptyrust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp#Empty#
123 }
124
125 /// create a String type symbolic-expression
126 #[deprecated(since = "4.0.3", note = "please use `.into()` instead")]
127 pub fn new_stringrust-analyzer cargo symbolic_expressions 5.0.3 sexp/impl#[Sexp]new_string().<T>(s: T) -> Sexprust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp#
128 where
129 T: fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display#,
130 {
131 formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{}", s).intorust-analyzer cargo symbolic_expressions 5.0.3 sexp/impl#[String][`Into<Sexp>`]into().()
132 }
133
134 /// create a list type symbolic-expression
135 #[deprecated(since = "4.0.3", note = "please use `.into()` instead")]
136 pub fn new_listrust-analyzer cargo symbolic_expressions 5.0.3 sexp/impl#[Sexp]new_list().(v: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Sexprust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp#>) -> Sexprust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp# {
137 Sexprust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp#::Listrust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp#List#(v)
138 }
139
140 /// create an empty list type symbolic-expression
141 pub fn startrust-analyzer cargo symbolic_expressions 5.0.3 sexp/impl#[Sexp]start().(name: &str) -> Sexprust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp# {
142 let mut v = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![];
143 v.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(Sexprust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp#::Stringrust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp#String#(name.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()));
144 Sexprust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp#::Listrust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp#List#(v)
145 }
146
147 /// push an element in a list
148 pub fn pushrust-analyzer cargo symbolic_expressions 5.0.3 sexp/impl#[Sexp]push().<T: Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<Sexprust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp#>>(&mut self, element: T) {
149 match *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().self {
150 Sexprust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp#::Listrust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp#List#(ref mut v) => v.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(element.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().()),
151 _ => panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("Only use push on lists!"),
152 }
153 }
154
155 /// create a list type symbolic-expression where
156 /// the first element of the list is a string that indicates
157 /// the name, the remainder is filled in via the provided
158 /// fill function
159 ///
160 /// shape: (name ...)
161 pub fn new_named_listrust-analyzer cargo symbolic_expressions 5.0.3 sexp/impl#[Sexp]new_named_list().<F>(name: &str, fill: F) -> Sexprust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp#
162 where
163 F: Fnrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/function/Fn#(&mut Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Sexprust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp#>),
164 {
165 let mut v = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![];
166 v.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(name.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
167 fill(&mut v);
168 Sexprust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp#::Listrust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp#List#(v)
169 }
170
171 /// create a list type symbolic-expression where
172 /// the first element of the list is a string that indicates
173 /// the name
174 #[deprecated(since = "4.0.3", note = "please use `.into()` instead")]
175 pub fn new_namedrust-analyzer cargo symbolic_expressions 5.0.3 sexp/impl#[Sexp]new_named().<T>(name: &str, value: T) -> Sexprust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp#
176 where
177 T: fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display#,
178 {
179 let mut v = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![];
180 v.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(name.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
181 v.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{}", value).intorust-analyzer cargo symbolic_expressions 5.0.3 sexp/impl#[String][`Into<Sexp>`]into().());
182 v.intorust-analyzer cargo symbolic_expressions 5.0.3 sexp/impl#[`Vec<Sexp>`][`Into<Sexp>`]into().()
183 }
184
185 /// create a list type symbolic-expression where
186 /// the first element of the list is a string that indicates
187 /// the name, and the second is another symbolic-expression
188 /// created via the IntoSexp trait
189 #[deprecated(since = "4.0.5", note = "please use `.into()` on a tuple instead")]
190 pub fn new_named_sexprust-analyzer cargo symbolic_expressions 5.0.3 sexp/impl#[Sexp]new_named_sexp().<T>(name: &str, value: &T) -> Sexprust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp#
191 where
192 T: IntoSexprust-analyzer cargo symbolic_expressions 5.0.3 sexp/IntoSexp#,
193 {
194 let mut v = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![];
195 v.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(name.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
196 v.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(value.into_sexprust-analyzer cargo symbolic_expressions 5.0.3 sexp/IntoSexp#into_sexp().());
197 Sexprust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp#::Listrust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp#List#(v)
198 }
199
200 /// if the expression is a list, extract the `Vec<Sexp>`
201 /// from it and swap it with Empty
202 pub fn take_listrust-analyzer cargo symbolic_expressions 5.0.3 sexp/impl#[Sexp]take_list().(&mut self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Sexprust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp#>, SexpErrorrust-analyzer cargo symbolic_expressions 5.0.3 error/SexpError#> {
203 let mut e = Sexprust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp#::Emptyrust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp#Empty#;
204 memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/::swaprust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/swap().(&mut e, self);
205 match e {
206 Sexprust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp#::Listrust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp#List#(v) => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(v),
207 _ => Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("Not a list: {}", e).intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()),
208 }
209 }
210
211 /// if the expression is a `String`, take it out and swap it with Empty
212 pub fn take_stringrust-analyzer cargo symbolic_expressions 5.0.3 sexp/impl#[Sexp]take_string().(&mut self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, SexpErrorrust-analyzer cargo symbolic_expressions 5.0.3 error/SexpError#> {
213 let mut e = Sexprust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp#::Emptyrust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp#Empty#;
214 memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/::swaprust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/swap().(&mut e, self);
215 match e {
216 Sexprust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp#::Stringrust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp#String#(s) => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(s),
217 _ => Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("Not a string: {}", e).intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()),
218 }
219 }
220
221 /// create a symbolic-expression via the `IntoSexp` trait
222 pub fn fromrust-analyzer cargo symbolic_expressions 5.0.3 sexp/impl#[Sexp]from().<T: IntoSexprust-analyzer cargo symbolic_expressions 5.0.3 sexp/IntoSexp#>(t: &T) -> Sexprust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp# {
223 t.into_sexprust-analyzer cargo symbolic_expressions 5.0.3 sexp/IntoSexp#into_sexp().()
224 }
225
226 /// access the symbolic-expression as if it is a List
227 pub fn listrust-analyzer cargo symbolic_expressions 5.0.3 sexp/impl#[Sexp]list().(&self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<&Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Sexprust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp#>, SexpErrorrust-analyzer cargo symbolic_expressions 5.0.3 error/SexpError#> {
228 match *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self {
229 Sexprust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp#::Listrust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp#List#(ref v) => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(v),
230 _ => Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("not a list: {}", self).intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()),
231 }
232 }
233
234 /// access the symbolic-expression as if it is an `&String`
235 pub fn stringrust-analyzer cargo symbolic_expressions 5.0.3 sexp/impl#[Sexp]string().(&self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<&Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, SexpErrorrust-analyzer cargo symbolic_expressions 5.0.3 error/SexpError#> {
236 match *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self {
237 Sexprust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp#::Stringrust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp#String#(ref s) => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(s),
238 _ => Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("not a string: {}", self).intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()),
239 }
240 }
241
242 /// access the symbolic-expression as if it is a `String`
243 pub fn srust-analyzer cargo symbolic_expressions 5.0.3 sexp/impl#[Sexp]s().(&self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, SexpErrorrust-analyzer cargo symbolic_expressions 5.0.3 error/SexpError#> {
244 match *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self {
245 Sexprust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp#::Stringrust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp#String#(ref s) => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(s.clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][Clone]clone().()),
246 _ => Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("not a string: {}", self).intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()),
247 }
248 }
249
250 /// is this expression a string
251 pub fn is_stringrust-analyzer cargo symbolic_expressions 5.0.3 sexp/impl#[Sexp]is_string().(&self) -> bool {
252 match *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self {
253 Sexprust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp#::Stringrust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp#String#(_) => true,
254 _ => false,
255 }
256 }
257
258 /// is this expression a list
259 pub fn is_listrust-analyzer cargo symbolic_expressions 5.0.3 sexp/impl#[Sexp]is_list().(&self) -> bool {
260 match *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self {
261 Sexprust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp#::Listrust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp#List#(_) => true,
262 _ => false,
263 }
264 }
265
266 /// access the symbolic-expression as if it is a String
267 /// that is a f64
268 pub fn frust-analyzer cargo symbolic_expressions 5.0.3 sexp/impl#[Sexp]f().(&self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<f64, SexpErrorrust-analyzer cargo symbolic_expressions 5.0.3 error/SexpError#> {
269 let s = self.stringrust-analyzer cargo symbolic_expressions 5.0.3 sexp/impl#[Sexp]string().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
270 let f = s.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
271 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(f)
272 }
273
274 /// access the symbolic-expression as if it is a String
275 /// that is an i64
276 pub fn irust-analyzer cargo symbolic_expressions 5.0.3 sexp/impl#[Sexp]i().(&self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<i64, SexpErrorrust-analyzer cargo symbolic_expressions 5.0.3 error/SexpError#> {
277 let s = self.stringrust-analyzer cargo symbolic_expressions 5.0.3 sexp/impl#[Sexp]string().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
278 let i = s.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
279 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(i)
280 }
281
282 /// access the symbolic-expression as if it is a List
283 /// assuming the first element is a String and return that
284 pub fn list_namerust-analyzer cargo symbolic_expressions 5.0.3 sexp/impl#[Sexp]list_name().(&self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<&Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, SexpErrorrust-analyzer cargo symbolic_expressions 5.0.3 error/SexpError#> {
285 let l = self.listrust-analyzer cargo symbolic_expressions 5.0.3 sexp/impl#[Sexp]list().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
286 let l = &l[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFull#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().;
287 let a = l[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..stringrust-analyzer cargo symbolic_expressions 5.0.3 sexp/impl#[Sexp]string().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
288 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(a)
289 }
290
291 /// access the symbolic-expression as if it is a named List
292 /// where the name is provided and returns the remaining elements
293 /// after the name as a slice
294 #[deprecated(since = "4.1.4", note = "please use `iteratom::IterAtom::new` instead")]
295 pub fn slice_atomrust-analyzer cargo symbolic_expressions 5.0.3 sexp/impl#[Sexp]slice_atom().(&self, s: &str) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<&[Sexprust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp#], SexpErrorrust-analyzer cargo symbolic_expressions 5.0.3 error/SexpError#> {
296 let v = self.listrust-analyzer cargo symbolic_expressions 5.0.3 sexp/impl#[Sexp]list().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
297 let v2 = &v[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFull#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().;
298 let st = v2[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..stringrust-analyzer cargo symbolic_expressions 5.0.3 sexp/impl#[Sexp]string().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
299 if st rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]ne().s {
300 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("list {} doesn't start with {}, but with {}", self, s, st).intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
301 };
302 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(&v[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().1..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().)
303 }
304
305 fn slice_atom_intrust-analyzer cargo symbolic_expressions 5.0.3 sexp/impl#[Sexp]slice_atom_int().(&self, s: &str) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<&[Sexprust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp#], SexpErrorrust-analyzer cargo symbolic_expressions 5.0.3 error/SexpError#> {
306 let v = self.listrust-analyzer cargo symbolic_expressions 5.0.3 sexp/impl#[Sexp]list().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
307 let v2 = &v[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFull#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().;
308 let st = v2[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..stringrust-analyzer cargo symbolic_expressions 5.0.3 sexp/impl#[Sexp]string().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
309 if st rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]ne().s {
310 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("list {} doesn't start with {}, but with {}", self, s, st).intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
311 };
312 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(&v[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().1..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().)
313 }
314
315 /// access the symbolic-expression as if it is a named List
316 /// with two elements where the name is provided and returns
317 /// the next element in the list
318 pub fn named_valuerust-analyzer cargo symbolic_expressions 5.0.3 sexp/impl#[Sexp]named_value().(&self, s: &str) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<&Sexprust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp#, SexpErrorrust-analyzer cargo symbolic_expressions 5.0.3 error/SexpError#> {
319 let v = self.listrust-analyzer cargo symbolic_expressions 5.0.3 sexp/impl#[Sexp]list().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
320 if v.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().2 {
321 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("list {} is not a named_value", s).intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
322 }
323 let l = self.slice_atom_intrust-analyzer cargo symbolic_expressions 5.0.3 sexp/impl#[Sexp]slice_atom_int().(s)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
324 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(&l[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().)
325 }
326
327 /// as named_value but converted to i64
328 pub fn named_value_irust-analyzer cargo symbolic_expressions 5.0.3 sexp/impl#[Sexp]named_value_i().(&self, s: &str) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<i64, SexpErrorrust-analyzer cargo symbolic_expressions 5.0.3 error/SexpError#> {
329 self.named_valuerust-analyzer cargo symbolic_expressions 5.0.3 sexp/impl#[Sexp]named_value().(s)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()..irust-analyzer cargo symbolic_expressions 5.0.3 sexp/impl#[Sexp]i().()
330 }
331
332 /// as named_value but converted to f64
333 pub fn named_value_frust-analyzer cargo symbolic_expressions 5.0.3 sexp/impl#[Sexp]named_value_f().(&self, s: &str) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<f64, SexpErrorrust-analyzer cargo symbolic_expressions 5.0.3 error/SexpError#> {
334 self.named_valuerust-analyzer cargo symbolic_expressions 5.0.3 sexp/impl#[Sexp]named_value().(s)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()..frust-analyzer cargo symbolic_expressions 5.0.3 sexp/impl#[Sexp]f().()
335 }
336
337 /// as named_value but converted to `&String`
338 pub fn named_value_stringrust-analyzer cargo symbolic_expressions 5.0.3 sexp/impl#[Sexp]named_value_string().(&self, s: &str) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<&Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, SexpErrorrust-analyzer cargo symbolic_expressions 5.0.3 error/SexpError#> {
339 self.named_valuerust-analyzer cargo symbolic_expressions 5.0.3 sexp/impl#[Sexp]named_value().(s)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()..stringrust-analyzer cargo symbolic_expressions 5.0.3 sexp/impl#[Sexp]string().()
340 }
341
342 /// as named_value but converted to `String`
343 pub fn named_value_srust-analyzer cargo symbolic_expressions 5.0.3 sexp/impl#[Sexp]named_value_s().(&self, s: &str) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, SexpErrorrust-analyzer cargo symbolic_expressions 5.0.3 error/SexpError#> {
344 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(self.named_valuerust-analyzer cargo symbolic_expressions 5.0.3 sexp/impl#[Sexp]named_value().(s)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()..stringrust-analyzer cargo symbolic_expressions 5.0.3 sexp/impl#[Sexp]string().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()..clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][Clone]clone().())
345 }
346
347 /// get the symbolic-expression as a list which starts
348 /// with a string that indicates the name and has num more
349 /// elements, returns those elements
350 #[deprecated(since = "4.1.4", note = "please use `iteratom::IterAtom::new` instead")]
351 pub fn slice_atom_numrust-analyzer cargo symbolic_expressions 5.0.3 sexp/impl#[Sexp]slice_atom_num().(&self, s: &str, num: usize) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<&[Sexprust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp#], SexpErrorrust-analyzer cargo symbolic_expressions 5.0.3 error/SexpError#> {
352 let v = self.listrust-analyzer cargo symbolic_expressions 5.0.3 sexp/impl#[Sexp]list().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
353 let v2 = &v[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFull#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().;
354 let st = v2[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..stringrust-analyzer cargo symbolic_expressions 5.0.3 sexp/impl#[Sexp]string().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
355 if st rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]ne().s {
356 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("list doesn't start with {}, but with {}", s, st).intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
357 };
358 if v.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().(num rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().1) {
359 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(
360 formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!(
361 "list ({}) doesn't have {} elements but {}",
362 s,
363 num,
364 v.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().() -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). 1
365 ).intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(),
366 );
367 }
368 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(&v[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().1..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().)
369 }
370 }
371
372 impl fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# for Sexprust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp# {
373 fn fmtrust-analyzer cargo symbolic_expressions 5.0.3 sexp/impl#[Sexp][Display]fmt().(&self, f: &mut fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Error#> {
374 match *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self {
375 Sexprust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp#::Stringrust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp#String#(ref s) => writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "{}", encode_stringrust-analyzer cargo symbolic_expressions 5.0.3 sexp/encode_string().(s)),
376 Sexprust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp#::Listrust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp#List#(ref v) => {
377 writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "(")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
378 let l = v.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().();
379 for (i, x) in v.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().enumeraterust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#enumerate().() {
380 if i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().l rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().1 {
381 writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "{} ", x)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
382 } else {
383 writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "{}", x)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
384 }
385 }
386 writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, ")")
387 }
388 Sexprust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp#::Emptyrust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp#Empty# => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()),
389 }
390 }
391 }
392
393 impl Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default# for Sexprust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp# {
394 fn defaultrust-analyzer cargo symbolic_expressions 5.0.3 sexp/impl#[Sexp][Default]default().() -> Sexprust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp# {
395 Sexprust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp#::Emptyrust-analyzer cargo symbolic_expressions 5.0.3 sexp/Sexp#Empty#
396 }
397 }