Debian Codegraph @

src/lossless.rs

raw symbols SCIP
1 //! A library for parsing and manipulating R DESCRIPTION files.
2 //!
3 //! This module allows losslessly parsing R DESCRIPTION files into a structured representation.
4 //! This allows modification of individual fields while preserving the
5 //! original formatting of the file.
6 //!
7 //! This parser also allows for syntax errors in the input, and will attempt to parse as much as
8 //! possible.
9 //!
10 //! See https://r-pkgs.org/description.html for more information.
11
12 use craterust-analyzer cargo r-description 0.4.1 crate/::RCoderust-analyzer cargo r-description 0.4.1 RCode#;
13 use deb822_losslessrust-analyzer cargo deb822-lossless 0.5.18 crate/::Paragraphrust-analyzer cargo deb822-lossless 0.5.18 lossless/Paragraph#;
14 pub use relationsrust-analyzer cargo r-description 0.4.1 lossless/relations/::{Relationrust-analyzer cargo r-description 0.4.1 lossless/relations/Relation#, Relationsrust-analyzer cargo r-description 0.4.1 lossless/relations/Relations#, Versionrust-analyzer cargo r-description 0.4.1 lossless/relations/Version#};
15
16 /// R DESCRIPTION file
17 pub struct RDescriptionrust-analyzer cargo r-description 0.4.1 lossless/RDescription#(Paragraphrust-analyzer cargo deb822-lossless 0.5.18 lossless/Paragraph#);
18
19 impl 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/::Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# for RDescriptionrust-analyzer cargo r-description 0.4.1 lossless/RDescription# {
20 fn fmtrust-analyzer cargo r-description 0.4.1 lossless/impl#[RDescription][Display]fmt().(&self, f: &mut 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/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#) -> 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/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# {
21 writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "{}", self.0rust-analyzer cargo r-description 0.4.1 lossless/RDescription#0.)
22 }
23 }
24
25 impl Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default# for RDescriptionrust-analyzer cargo r-description 0.4.1 lossless/RDescription# {
26 fn defaultrust-analyzer cargo r-description 0.4.1 lossless/impl#[RDescription][Default]default().() -> Selfrust-analyzer cargo r-description 0.4.1 lossless/impl#[RDescription][Default] {
27 Selfrust-analyzer cargo r-description 0.4.1 lossless/impl#[RDescription][Default](Paragraphrust-analyzer cargo deb822-lossless 0.5.18 lossless/Paragraph#::newrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]new().())
28 }
29 }
30
31 impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<RDescriptionrust-analyzer cargo r-description 0.4.1 lossless/RDescription#> for Paragraphrust-analyzer cargo deb822-lossless 0.5.18 lossless/Paragraph# {
32 fn fromrust-analyzer cargo r-description 0.4.1 lossless/impl#[Paragraph][`From<RDescription>`]from().(description: RDescriptionrust-analyzer cargo r-description 0.4.1 lossless/RDescription#) -> Selfrust-analyzer cargo r-description 0.4.1 lossless/impl#[Paragraph][`From<RDescription>`] {
33 description.0rust-analyzer cargo r-description 0.4.1 lossless/RDescription#0.
34 }
35 }
36
37 impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<Paragraphrust-analyzer cargo deb822-lossless 0.5.18 lossless/Paragraph#> for RDescriptionrust-analyzer cargo r-description 0.4.1 lossless/RDescription# {
38 fn fromrust-analyzer cargo r-description 0.4.1 lossless/impl#[RDescription][`From<Paragraph>`]from().(paragraph: Paragraphrust-analyzer cargo deb822-lossless 0.5.18 lossless/Paragraph#) -> Selfrust-analyzer cargo r-description 0.4.1 lossless/impl#[RDescription][`From<Paragraph>`] {
39 Selfrust-analyzer cargo r-description 0.4.1 lossless/impl#[RDescription][`From<Paragraph>`](paragraph)
40 }
41 }
42
43 #[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:)]
44 /// Error type for parsing DESCRIPTION files
45 pub enum Errorrust-analyzer cargo r-description 0.4.1 lossless/Error# {
46 /// I/O error
47 Iorust-analyzer cargo r-description 0.4.1 lossless/Error#Io#(stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#),
48
49 /// Parse error
50 Parserust-analyzer cargo r-description 0.4.1 lossless/Error#Parse#(deb822_losslessrust-analyzer cargo deb822-lossless 0.5.18 crate/::ParseErrorrust-analyzer cargo deb822-lossless 0.5.18 lossless/ParseError#),
51 }
52
53 impl 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/::Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# for Errorrust-analyzer cargo r-description 0.4.1 lossless/Error# {
54 fn fmtrust-analyzer cargo r-description 0.4.1 lossless/impl#[Error][Display]fmt().(&self, f: &mut 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/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#) -> 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/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# {
55 match self {
56 Selfrust-analyzer cargo r-description 0.4.1 lossless/impl#[Error][Display]::Iorust-analyzer cargo r-description 0.4.1 lossless/Error#Io#(e) => writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "IO error: {e}"),
57 Selfrust-analyzer cargo r-description 0.4.1 lossless/impl#[Error][Display]::Parserust-analyzer cargo r-description 0.4.1 lossless/Error#Parse#(e) => writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "Parse error: {e}"),
58 }
59 }
60 }
61
62 impl stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std error/::Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# for Errorrust-analyzer cargo r-description 0.4.1 lossless/Error# {}
63
64 impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<deb822_losslessrust-analyzer cargo deb822-lossless 0.5.18 crate/::ParseErrorrust-analyzer cargo deb822-lossless 0.5.18 lossless/ParseError#> for Errorrust-analyzer cargo r-description 0.4.1 lossless/Error# {
65 fn fromrust-analyzer cargo r-description 0.4.1 lossless/impl#[Error][`From<deb822_lossless::ParseError>`]from().(e: deb822_losslessrust-analyzer cargo deb822-lossless 0.5.18 crate/::ParseErrorrust-analyzer cargo deb822-lossless 0.5.18 lossless/ParseError#) -> Selfrust-analyzer cargo r-description 0.4.1 lossless/impl#[Error][`From<deb822_lossless::ParseError>`] {
66 Selfrust-analyzer cargo r-description 0.4.1 lossless/impl#[Error][`From<deb822_lossless::ParseError>`]::Parserust-analyzer cargo r-description 0.4.1 lossless/Error#Parse#(e)
67 }
68 }
69
70 impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#> for Errorrust-analyzer cargo r-description 0.4.1 lossless/Error# {
71 fn fromrust-analyzer cargo r-description 0.4.1 lossless/impl#[Error][`From<std::io::Error>`]from().(e: stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#) -> Selfrust-analyzer cargo r-description 0.4.1 lossless/impl#[Error][`From<std::io::Error>`] {
72 Selfrust-analyzer cargo r-description 0.4.1 lossless/impl#[Error][`From<std::io::Error>`]::Iorust-analyzer cargo r-description 0.4.1 lossless/Error#Io#(e)
73 }
74 }
75
76 impl stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/::FromStrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/traits/FromStr# for RDescriptionrust-analyzer cargo r-description 0.4.1 lossless/RDescription# {
77 type Errrust-analyzer cargo r-description 0.4.1 lossless/impl#[RDescription][FromStr]Err# = Errorrust-analyzer cargo r-description 0.4.1 lossless/Error#;
78
79 fn from_strrust-analyzer cargo r-description 0.4.1 lossless/impl#[RDescription][FromStr]from_str().(s: &str) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo r-description 0.4.1 lossless/impl#[RDescription][FromStr], Selfrust-analyzer cargo r-description 0.4.1 lossless/impl#[RDescription][FromStr]::Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/traits/FromStr#Err#> {
80 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo r-description 0.4.1 lossless/impl#[RDescription][FromStr](Paragraphrust-analyzer cargo deb822-lossless 0.5.18 lossless/Paragraph#::from_strrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph][FromStr]from_str().(s)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().))
81 }
82 }
83
84 impl RDescriptionrust-analyzer cargo r-description 0.4.1 lossless/RDescription# {
85 /// Create a new empty R DESCRIPTION file
86 pub fn newrust-analyzer cargo r-description 0.4.1 lossless/impl#[RDescription]new().() -> Selfrust-analyzer cargo r-description 0.4.1 lossless/impl#[RDescription] {
87 Selfrust-analyzer cargo r-description 0.4.1 lossless/impl#[RDescription](Paragraphrust-analyzer cargo deb822-lossless 0.5.18 lossless/Paragraph#::newrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]new().())
88 }
89
90 /// Return the package name
91 pub fn packagerust-analyzer cargo r-description 0.4.1 lossless/impl#[RDescription]package().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> {
92 self.0rust-analyzer cargo r-description 0.4.1 lossless/RDescription#0..getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("Package")
93 }
94
95 /// Set the package name
96 pub fn set_packagerust-analyzer cargo r-description 0.4.1 lossless/impl#[RDescription]set_package().(&mut self, package: &str) {
97 self.0rust-analyzer cargo r-description 0.4.1 lossless/RDescription#0..setrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]set().("Package", package);
98 }
99
100 /// One line description of the package, and is often shown in a package listing
101 ///
102 /// It should be plain text (no markup), capitalised like a title, and NOT end in a period.
103 /// Keep it short: listings will often truncate the title to 65 characters.
104 pub fn titlerust-analyzer cargo r-description 0.4.1 lossless/impl#[RDescription]title().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> {
105 self.0rust-analyzer cargo r-description 0.4.1 lossless/RDescription#0..getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("Title")
106 }
107
108 /// Return the maintainer of the package
109 pub fn maintainerrust-analyzer cargo r-description 0.4.1 lossless/impl#[RDescription]maintainer().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> {
110 self.0rust-analyzer cargo r-description 0.4.1 lossless/RDescription#0..getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("Maintainer")
111 }
112
113 /// Set the maintainer of the package
114 pub fn set_maintainerrust-analyzer cargo r-description 0.4.1 lossless/impl#[RDescription]set_maintainer().(&mut self, maintainer: &str) {
115 self.0rust-analyzer cargo r-description 0.4.1 lossless/RDescription#0..setrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]set().("Maintainer", maintainer);
116 }
117
118 /// Return the authors of the package
119 pub fn authorsrust-analyzer cargo r-description 0.4.1 lossless/impl#[RDescription]authors().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<RCoderust-analyzer cargo r-description 0.4.1 RCode#> {
120 self.0rust-analyzer cargo r-description 0.4.1 lossless/RDescription#0..getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("Authors@R").maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|s| s.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().())
121 }
122
123 /// Set the authors of the package
124 pub fn set_authorsrust-analyzer cargo r-description 0.4.1 lossless/impl#[RDescription]set_authors().(&mut self, authors: &RCoderust-analyzer cargo r-description 0.4.1 RCode#) {
125 self.0rust-analyzer cargo r-description 0.4.1 lossless/RDescription#0..setrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]set().("Authors@R", &authors.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().());
126 }
127
128 /// Set the title of the package
129 pub fn set_titlerust-analyzer cargo r-description 0.4.1 lossless/impl#[RDescription]set_title().(&mut self, title: &str) {
130 self.0rust-analyzer cargo r-description 0.4.1 lossless/RDescription#0..setrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]set().("Title", title);
131 }
132
133 /// Return the description of the package
134 pub fn descriptionrust-analyzer cargo r-description 0.4.1 lossless/impl#[RDescription]description().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> {
135 self.0rust-analyzer cargo r-description 0.4.1 lossless/RDescription#0..getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("Description")
136 }
137
138 /// Set the description of the package
139 pub fn set_descriptionrust-analyzer cargo r-description 0.4.1 lossless/impl#[RDescription]set_description().(&mut self, description: &str) {
140 self.0rust-analyzer cargo r-description 0.4.1 lossless/RDescription#0..setrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]set().("Description", description);
141 }
142
143 /// Return the version of the package
144 pub fn versionrust-analyzer cargo r-description 0.4.1 lossless/impl#[RDescription]version().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> {
145 self.0rust-analyzer cargo r-description 0.4.1 lossless/RDescription#0..getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("Version")
146 }
147
148 /// Set the version of the package
149 pub fn set_versionrust-analyzer cargo r-description 0.4.1 lossless/impl#[RDescription]set_version().(&mut self, version: &str) {
150 self.0rust-analyzer cargo r-description 0.4.1 lossless/RDescription#0..setrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]set().("Version", version);
151 }
152
153 /// Return the encoding of the description file
154 pub fn encodingrust-analyzer cargo r-description 0.4.1 lossless/impl#[RDescription]encoding().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> {
155 self.0rust-analyzer cargo r-description 0.4.1 lossless/RDescription#0..getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("Encoding")
156 }
157
158 /// Set the encoding of the description file
159 pub fn set_encodingrust-analyzer cargo r-description 0.4.1 lossless/impl#[RDescription]set_encoding().(&mut self, encoding: &str) {
160 self.0rust-analyzer cargo r-description 0.4.1 lossless/RDescription#0..setrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]set().("Encoding", encoding);
161 }
162
163 /// Return the license of the package
164 pub fn licenserust-analyzer cargo r-description 0.4.1 lossless/impl#[RDescription]license().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> {
165 self.0rust-analyzer cargo r-description 0.4.1 lossless/RDescription#0..getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("License")
166 }
167
168 /// Set the license of the package
169 pub fn set_licenserust-analyzer cargo r-description 0.4.1 lossless/impl#[RDescription]set_license().(&mut self, license: &str) {
170 self.0rust-analyzer cargo r-description 0.4.1 lossless/RDescription#0..setrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]set().("License", license);
171 }
172
173 /// Return the roxygen note
174 pub fn roxygen_noterust-analyzer cargo r-description 0.4.1 lossless/impl#[RDescription]roxygen_note().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> {
175 self.0rust-analyzer cargo r-description 0.4.1 lossless/RDescription#0..getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("RoxygenNote")
176 }
177
178 /// Set the roxygen note
179 pub fn set_roxygen_noterust-analyzer cargo r-description 0.4.1 lossless/impl#[RDescription]set_roxygen_note().(&mut self, roxygen_note: &str) {
180 self.0rust-analyzer cargo r-description 0.4.1 lossless/RDescription#0..setrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]set().("RoxygenNote", roxygen_note);
181 }
182
183 /// Return the roxygen version
184 pub fn roxygenrust-analyzer cargo r-description 0.4.1 lossless/impl#[RDescription]roxygen().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> {
185 self.0rust-analyzer cargo r-description 0.4.1 lossless/RDescription#0..getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("Roxygen")
186 }
187
188 /// Set the roxygen version
189 pub fn set_roxygenrust-analyzer cargo r-description 0.4.1 lossless/impl#[RDescription]set_roxygen().(&mut self, roxygen: &str) {
190 self.0rust-analyzer cargo r-description 0.4.1 lossless/RDescription#0..setrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]set().("Roxygen", roxygen);
191 }
192
193 /// Return the URL field
194 pub fn urlrust-analyzer cargo r-description 0.4.1 lossless/impl#[RDescription]url().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> {
195 // TODO: parse list of URLs, separated by commas
196 self.0rust-analyzer cargo r-description 0.4.1 lossless/RDescription#0..getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("URL")
197 }
198
199 /// Set the URL field
200 pub fn set_urlrust-analyzer cargo r-description 0.4.1 lossless/impl#[RDescription]set_url().(&mut self, url: &str) {
201 // TODO: parse list of URLs, separated by commas
202 self.0rust-analyzer cargo r-description 0.4.1 lossless/RDescription#0..setrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]set().("URL", url);
203 }
204
205 /// Return the bug reports URL
206 pub fn bug_reportsrust-analyzer cargo r-description 0.4.1 lossless/impl#[RDescription]bug_reports().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<urlrust-analyzer cargo url 2.5.8 crate/::Urlrust-analyzer cargo url 2.5.8 Url#> {
207 self.0rust-analyzer cargo r-description 0.4.1 lossless/RDescription#0.
208 .getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("BugReports")
209 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|s| urlrust-analyzer cargo url 2.5.8 crate/::Urlrust-analyzer cargo url 2.5.8 Url#::parserust-analyzer cargo url 2.5.8 impl#[Url]parse().(s.as_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]as_str().()).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().())
210 }
211
212 /// Set the bug reports URL
213 pub fn set_bug_reportsrust-analyzer cargo r-description 0.4.1 lossless/impl#[RDescription]set_bug_reports().(&mut self, bug_reports: &urlrust-analyzer cargo url 2.5.8 crate/::Urlrust-analyzer cargo url 2.5.8 Url#) {
214 self.0rust-analyzer cargo r-description 0.4.1 lossless/RDescription#0..setrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]set().("BugReports", bug_reports.as_strrust-analyzer cargo url 2.5.8 impl#[Url]as_str().());
215 }
216
217 /// Return the imports field
218 pub fn importsrust-analyzer cargo r-description 0.4.1 lossless/impl#[RDescription]imports().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Relationsrust-analyzer cargo r-description 0.4.1 lossless/relations/Relations#> {
219 self.0rust-analyzer cargo r-description 0.4.1 lossless/RDescription#0..getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("Imports").maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|s| s.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().())
220 }
221
222 /// Set the imports field
223 pub fn set_importsrust-analyzer cargo r-description 0.4.1 lossless/impl#[RDescription]set_imports().(&mut self, imports: Relationsrust-analyzer cargo r-description 0.4.1 lossless/relations/Relations#) {
224 self.0rust-analyzer cargo r-description 0.4.1 lossless/RDescription#0..setrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]set().("Imports", &imports.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().());
225 }
226
227 /// Return the suggests field
228 pub fn suggestsrust-analyzer cargo r-description 0.4.1 lossless/impl#[RDescription]suggests().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Relationsrust-analyzer cargo r-description 0.4.1 lossless/relations/Relations#> {
229 self.0rust-analyzer cargo r-description 0.4.1 lossless/RDescription#0..getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("Suggests").maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|s| s.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().())
230 }
231
232 /// Set the suggests field
233 pub fn set_suggestsrust-analyzer cargo r-description 0.4.1 lossless/impl#[RDescription]set_suggests().(&mut self, suggests: Relationsrust-analyzer cargo r-description 0.4.1 lossless/relations/Relations#) {
234 self.0rust-analyzer cargo r-description 0.4.1 lossless/RDescription#0..setrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]set().("Suggests", &suggests.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().());
235 }
236
237 /// Return the depends field
238 pub fn dependsrust-analyzer cargo r-description 0.4.1 lossless/impl#[RDescription]depends().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Relationsrust-analyzer cargo r-description 0.4.1 lossless/relations/Relations#> {
239 self.0rust-analyzer cargo r-description 0.4.1 lossless/RDescription#0..getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("Depends").maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|s| s.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().())
240 }
241
242 /// Set the depends field
243 pub fn set_dependsrust-analyzer cargo r-description 0.4.1 lossless/impl#[RDescription]set_depends().(&mut self, depends: Relationsrust-analyzer cargo r-description 0.4.1 lossless/relations/Relations#) {
244 self.0rust-analyzer cargo r-description 0.4.1 lossless/RDescription#0..setrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]set().("Depends", &depends.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().());
245 }
246
247 /// Return the linking-to field
248 pub fn linking_torust-analyzer cargo r-description 0.4.1 lossless/impl#[RDescription]linking_to().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Relationsrust-analyzer cargo r-description 0.4.1 lossless/relations/Relations#> {
249 self.0rust-analyzer cargo r-description 0.4.1 lossless/RDescription#0..getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("LinkingTo").maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|s| s.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().())
250 }
251
252 /// Set the linking-to field
253 pub fn set_linking_torust-analyzer cargo r-description 0.4.1 lossless/impl#[RDescription]set_linking_to().(&mut self, linking_to: Relationsrust-analyzer cargo r-description 0.4.1 lossless/relations/Relations#) {
254 self.0rust-analyzer cargo r-description 0.4.1 lossless/RDescription#0..setrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]set().("LinkingTo", &linking_to.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().());
255 }
256
257 /// Return the enhances field
258 pub fn enhancesrust-analyzer cargo r-description 0.4.1 lossless/impl#[RDescription]enhances().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Relationsrust-analyzer cargo r-description 0.4.1 lossless/relations/Relations#> {
259 self.0rust-analyzer cargo r-description 0.4.1 lossless/RDescription#0..getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("Enhances").maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|s| s.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().())
260 }
261
262 /// Set the enhances field
263 pub fn set_enhancesrust-analyzer cargo r-description 0.4.1 lossless/impl#[RDescription]set_enhances().(&mut self, enhances: Relationsrust-analyzer cargo r-description 0.4.1 lossless/relations/Relations#) {
264 self.0rust-analyzer cargo r-description 0.4.1 lossless/RDescription#0..setrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]set().("Enhances", &enhances.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().());
265 }
266
267 /// Return the lazy data field
268 pub fn lazy_datarust-analyzer cargo r-description 0.4.1 lossless/impl#[RDescription]lazy_data().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<bool> {
269 self.0rust-analyzer cargo r-description 0.4.1 lossless/RDescription#0..getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("LazyData").maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|s| s rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`PartialEq<&str>`]eq().==rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`PartialEq<&str>`]eq(). rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`PartialEq<&str>`]eq()."true")
270 }
271
272 /// Set the lazy data field
273 pub fn set_lazy_datarust-analyzer cargo r-description 0.4.1 lossless/impl#[RDescription]set_lazy_data().(&mut self, lazy_data: bool) {
274 self.0rust-analyzer cargo r-description 0.4.1 lossless/RDescription#0.
275 .setrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]set().("LazyData", if lazy_data { "true" } else { "false" });
276 }
277
278 /// Return the collate field
279 pub fn collaterust-analyzer cargo r-description 0.4.1 lossless/impl#[RDescription]collate().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> {
280 self.0rust-analyzer cargo r-description 0.4.1 lossless/RDescription#0..getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("Collate")
281 }
282
283 /// Set the collate field
284 pub fn set_collaterust-analyzer cargo r-description 0.4.1 lossless/impl#[RDescription]set_collate().(&mut self, collate: &str) {
285 self.0rust-analyzer cargo r-description 0.4.1 lossless/RDescription#0..setrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]set().("Collate", collate);
286 }
287
288 /// Return the vignette builder field
289 pub fn vignette_builderrust-analyzer cargo r-description 0.4.1 lossless/impl#[RDescription]vignette_builder().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>> {
290 self.0rust-analyzer cargo r-description 0.4.1 lossless/RDescription#0.
291 .getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("VignetteBuilder")
292 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|s| s.splitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]split().(',').maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|s| s.trimrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]trim().().to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().())
293 }
294
295 /// Set the vignette builder field
296 pub fn set_vignette_builderrust-analyzer cargo r-description 0.4.1 lossless/impl#[RDescription]set_vignette_builder().(&mut self, vignette_builder: &[&str]) {
297 self.0rust-analyzer cargo r-description 0.4.1 lossless/RDescription#0..setrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]set().("VignetteBuilder", &vignette_builder.joinrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]join().(", "));
298 }
299
300 /// Return the system requirements field
301 pub fn system_requirementsrust-analyzer cargo r-description 0.4.1 lossless/impl#[RDescription]system_requirements().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>> {
302 self.0rust-analyzer cargo r-description 0.4.1 lossless/RDescription#0.
303 .getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("SystemRequirements")
304 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|s| s.splitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]split().(',').maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|s| s.trimrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]trim().().to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().())
305 }
306
307 /// Set the system requirements field
308 pub fn set_system_requirementsrust-analyzer cargo r-description 0.4.1 lossless/impl#[RDescription]set_system_requirements().(&mut self, system_requirements: &[&str]) {
309 self.0rust-analyzer cargo r-description 0.4.1 lossless/RDescription#0.
310 .setrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]set().("SystemRequirements", &system_requirements.joinrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]join().(", "));
311 }
312
313 /// Return the date field
314 pub fn daterust-analyzer cargo r-description 0.4.1 lossless/impl#[RDescription]date().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> {
315 self.0rust-analyzer cargo r-description 0.4.1 lossless/RDescription#0..getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("Date")
316 }
317
318 /// Set the date field
319 pub fn set_daterust-analyzer cargo r-description 0.4.1 lossless/impl#[RDescription]set_date().(&mut self, date: &str) {
320 self.0rust-analyzer cargo r-description 0.4.1 lossless/RDescription#0..setrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]set().("Date", date);
321 }
322
323 /// The R Repository to use for this package.
324 ///
325 /// E.g. "CRAN" or "Bioconductor"
326 pub fn repositoryrust-analyzer cargo r-description 0.4.1 lossless/impl#[RDescription]repository().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> {
327 self.0rust-analyzer cargo r-description 0.4.1 lossless/RDescription#0..getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("Repository")
328 }
329
330 /// Set the R Repository to use for this package.
331 pub fn set_repositoryrust-analyzer cargo r-description 0.4.1 lossless/impl#[RDescription]set_repository().(&mut self, repository: &str) {
332 self.0rust-analyzer cargo r-description 0.4.1 lossless/RDescription#0..setrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]set().("Repository", repository);
333 }
334
335 /// Additional repositories where dependency packages may be found.
336 pub fn additional_repositoriesrust-analyzer cargo r-description 0.4.1 lossless/impl#[RDescription]additional_repositories().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>> {
337 self.0rust-analyzer cargo r-description 0.4.1 lossless/RDescription#0..getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("Additional_repositories").maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|s| {
338 s.splitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]split().(',')
339 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|s| s.trimrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]trim().().to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())
340 .filterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#filter().(|s| !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().s.is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]is_empty().())
341 .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().()
342 })
343 }
344
345 /// Set the additional repositories field.
346 pub fn set_additional_repositoriesrust-analyzer cargo r-description 0.4.1 lossless/impl#[RDescription]set_additional_repositories().(&mut self, repositories: &[&str]) {
347 self.0rust-analyzer cargo r-description 0.4.1 lossless/RDescription#0.
348 .setrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]set().("Additional_repositories", &repositories.joinrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]join().(", "));
349 }
350 }
351
352 pub mod relationsrust-analyzer cargo r-description 0.4.1 lossless/relations/ {
353 //! Parser for relationship fields like `Depends`, `Recommends`, etc.
354 //!
355 //! # Example
356 //! ```
357 //! use r_description::lossless::{Relations, Relation};
358 //! use r_description::VersionConstraint;
359 //!
360 //! let mut relations: Relations = r"cli (>= 0.19.0), R".parse().unwrap();
361 //! assert_eq!(relations.to_string(), "cli (>= 0.19.0), R");
362 //! assert!(relations.satisfied_by(|name: &str| -> Option<r_description::Version> {
363 //! match name {
364 //! "cli" => Some("0.19.0".parse().unwrap()),
365 //! "R" => Some("2.25.1".parse().unwrap()),
366 //! _ => None
367 //! }}));
368 //! relations.remove_relation(1);
369 //! assert_eq!(relations.to_string(), "cli (>= 0.19.0)");
370 //! ```
371 use craterust-analyzer cargo r-description 0.4.1 crate/::relationsrust-analyzer cargo r-description 0.4.1 relations/::SyntaxKindrust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#::{selfrust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#, *};
372 use craterust-analyzer cargo r-description 0.4.1 crate/::relationsrust-analyzer cargo r-description 0.4.1 relations/::VersionConstraintrust-analyzer cargo r-description 0.4.1 relations/VersionConstraint#;
373 use craterust-analyzer cargo r-description 0.4.1 crate/::versionrust-analyzer cargo r-description 0.4.1 version/::Versionrust-analyzer cargo r-description 0.4.1 version/Version# as LossyVersionrust-analyzer cargo r-description 0.4.1 version/Version#;
374 use rowanrust-analyzer cargo rowan 0.16.1 crate/::{Directionrust-analyzer cargo rowan 0.16.1 utility_types/Direction#, NodeOrTokenrust-analyzer cargo rowan 0.16.1 utility_types/NodeOrToken#};
375 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::cmprust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/::Orderingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ordering#;
376 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::hashrust-analyzer cargo std https://github.com/rust-lang/rust/library/std hash/::{Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash#, Hasherrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hasher#};
377
378 #[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:)]
379 /// Represents an R version string while preserving its original separators.
380 ///
381 /// R treats `.` and `-` as equivalent separators for comparison, but callers may
382 /// need to round-trip the exact spelling from DESCRIPTION relationship fields.
383 pub struct Versionrust-analyzer cargo r-description 0.4.1 lossless/relations/Version# {
384 /// Version components like [1, 2, 3]
385 pub componentsrust-analyzer cargo r-description 0.4.1 lossless/relations/Version#components.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u32>,
386 originalrust-analyzer cargo r-description 0.4.1 lossless/relations/Version#original.: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#,
387 }
388
389 impl Versionrust-analyzer cargo r-description 0.4.1 lossless/relations/Version# {
390 /// Return the original version string.
391 pub fn as_strrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Version]as_str().(&self) -> &str {
392 &self.originalrust-analyzer cargo r-description 0.4.1 lossless/relations/Version#original.
393 }
394 }
395
396 impl 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/::Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# for Versionrust-analyzer cargo r-description 0.4.1 lossless/relations/Version# {
397 fn fmtrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Version][Display]fmt().(&self, f: &mut 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/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#<'_>) -> 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/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# {
398 f.write_strrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/impl#[`Formatter<'a>`]write_str().(&self.originalrust-analyzer cargo r-description 0.4.1 lossless/relations/Version#original.)
399 }
400 }
401
402 impl stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/::FromStrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/traits/FromStr# for Versionrust-analyzer cargo r-description 0.4.1 lossless/relations/Version# {
403 type Errrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Version][FromStr]Err# = Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#;
404
405 fn from_strrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Version][FromStr]from_str().(s: &str) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Version][FromStr], Selfrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Version][FromStr]::Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/traits/FromStr#Err#> {
406 let components = s
407 .splitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]split().(|c| c rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq().'.' || c rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq().'-')
408 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|part| {
409 part.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().()
410 .map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(|_| formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("Invalid version component: {s}"))
411 })
412 .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<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#<_>, _>>()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
413
414 if components.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][`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().2 {
415 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!!("Invalid version string: {s}"));
416 }
417
418 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Version][FromStr] {
419 componentsrust-analyzer cargo r-description 0.4.1 lossless/relations/Version#components.,
420 originalrust-analyzer cargo r-description 0.4.1 lossless/relations/Version#original.: s.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(),
421 })
422 }
423 }
424
425 impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<Versionrust-analyzer cargo r-description 0.4.1 lossless/relations/Version#> for LossyVersionrust-analyzer cargo r-description 0.4.1 version/Version# {
426 fn fromrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[LossyVersion][`From<Version>`]from().(version: Versionrust-analyzer cargo r-description 0.4.1 lossless/relations/Version#) -> Selfrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[LossyVersion][`From<Version>`] {
427 Selfrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[LossyVersion][`From<Version>`] {
428 componentsrust-analyzer cargo r-description 0.4.1 version/Version#components.: version.componentsrust-analyzer cargo r-description 0.4.1 lossless/relations/Version#components.,
429 }
430 }
431 }
432
433 impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<LossyVersionrust-analyzer cargo r-description 0.4.1 version/Version#> for Versionrust-analyzer cargo r-description 0.4.1 lossless/relations/Version# {
434 fn fromrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Version][`From<LossyVersion>`]from().(version: LossyVersionrust-analyzer cargo r-description 0.4.1 version/Version#) -> Selfrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Version][`From<LossyVersion>`] {
435 let original = version.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().();
436 Selfrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Version][`From<LossyVersion>`] {
437 componentsrust-analyzer cargo r-description 0.4.1 lossless/relations/Version#components.: version.componentsrust-analyzer cargo r-description 0.4.1 version/Version#components.,
438 originalrust-analyzer cargo r-description 0.4.1 lossless/relations/Version#original.,
439 }
440 }
441 }
442
443 impl PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq# for Versionrust-analyzer cargo r-description 0.4.1 lossless/relations/Version# {
444 fn eqrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Version][`PartialEq<Self>`]eq().(&self, other: &Selfrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Version][`PartialEq<Self>`]) -> bool {
445 self.componentsrust-analyzer cargo r-description 0.4.1 lossless/relations/Version#components. rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/partial_eq/impl#[`Vec<T, A1>`][`PartialEq<Vec<U, A2>>`]eq().==rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/partial_eq/impl#[`Vec<T, A1>`][`PartialEq<Vec<U, A2>>`]eq(). rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/partial_eq/impl#[`Vec<T, A1>`][`PartialEq<Vec<U, A2>>`]eq().other.componentsrust-analyzer cargo r-description 0.4.1 lossless/relations/Version#components.
446 }
447 }
448
449 impl Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq# for Versionrust-analyzer cargo r-description 0.4.1 lossless/relations/Version# {}
450
451 impl Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash# for Versionrust-analyzer cargo r-description 0.4.1 lossless/relations/Version# {
452 fn hashrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Version][Hash]hash().<H: Hasherrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hasher#>(&self, state: &mut H) {
453 self.componentsrust-analyzer cargo r-description 0.4.1 lossless/relations/Version#components..hashrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][Hash]hash().(state);
454 }
455 }
456
457 impl Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord# for Versionrust-analyzer cargo r-description 0.4.1 lossless/relations/Version# {
458 fn cmprust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Version][Ord]cmp().(&self, other: &Selfrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Version][Ord]) -> Orderingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ordering# {
459 compare_componentsrust-analyzer cargo r-description 0.4.1 lossless/relations/compare_components().(&self.componentsrust-analyzer cargo r-description 0.4.1 lossless/relations/Version#components., &other.componentsrust-analyzer cargo r-description 0.4.1 lossless/relations/Version#components.)
460 }
461 }
462
463 impl PartialOrdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd# for Versionrust-analyzer cargo r-description 0.4.1 lossless/relations/Version# {
464 fn partial_cmprust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Version][`PartialOrd<Self>`]partial_cmp().(&self, other: &Selfrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Version][`PartialOrd<Self>`]) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Orderingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ordering#> {
465 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(self.cmprust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Version][Ord]cmp().(other))
466 }
467 }
468
469 fn compare_componentsrust-analyzer cargo r-description 0.4.1 lossless/relations/compare_components().(a_components: &[u32], b_components: &[u32]) -> Orderingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ordering# {
470 for (a, b) in a_components.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().ziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#zip().(b_components.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().()) {
471 match a.cmprust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][Ord]cmp().(b) {
472 Orderingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ordering#::Equalrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ordering#Equal# => continue,
473 ordering => return ordering,
474 }
475 }
476 a_components.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().().cmprust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][Ord]cmp().(&b_components.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().())
477 }
478
479 /// Error type for parsing relations fields
480 #[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:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/macros/Hash:)]
481 pub struct ParseErrorrust-analyzer cargo r-description 0.4.1 lossless/relations/ParseError#(Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>);
482
483 impl 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/::Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# for ParseErrorrust-analyzer cargo r-description 0.4.1 lossless/relations/ParseError# {
484 fn fmtrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[ParseError][Display]fmt().(&self, f: &mut 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/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#) -> 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/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# {
485 for err in &self.0rust-analyzer cargo r-description 0.4.1 lossless/relations/ParseError#0. {
486 writelnrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/writeln!!(f, "{err}")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
487 }
488 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
489 }
490 }
491
492 impl stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std error/::Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# for ParseErrorrust-analyzer cargo r-description 0.4.1 lossless/relations/ParseError# {}
493
494 /// Second, implementing the `Language` trait teaches rowan to convert between
495 /// these two SyntaxKind types, allowing for a nicer SyntaxNode API where
496 /// "kinds" are values from our `enum SyntaxKind`, instead of plain u16 values.
497 #[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:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, PartialOrdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd:, Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord:, Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/macros/Hash:)]
498 enum Langrust-analyzer cargo r-description 0.4.1 lossless/relations/Lang# {}
499 impl rowanrust-analyzer cargo rowan 0.16.1 crate/::Languagerust-analyzer cargo rowan 0.16.1 api/Language# for Langrust-analyzer cargo r-description 0.4.1 lossless/relations/Lang# {
500 type Kindrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Lang][Language]Kind# = SyntaxKindrust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#;
501 fn kind_from_rawrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Lang][Language]kind_from_raw().(raw: rowanrust-analyzer cargo rowan 0.16.1 crate/::SyntaxKindrust-analyzer cargo rowan 0.16.1 green/SyntaxKind#) -> Selfrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Lang][Language]::Kindrust-analyzer cargo rowan 0.16.1 api/Language#Kind# {
502 unsafe { 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/::transmuterust-analyzer cargo core https://github.com/rust-lang/rust/library/core intrinsics/transmute().::<u16, SyntaxKindrust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#>(raw.0rust-analyzer cargo rowan 0.16.1 green/SyntaxKind#0.) }
503 }
504 fn kind_to_rawrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Lang][Language]kind_to_raw().(kind: Selfrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Lang][Language]::Kindrust-analyzer cargo rowan 0.16.1 api/Language#Kind#) -> rowanrust-analyzer cargo rowan 0.16.1 crate/::SyntaxKindrust-analyzer cargo rowan 0.16.1 green/SyntaxKind# {
505 kind.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()
506 }
507 }
508
509 /// GreenNode is an immutable tree, which is cheap to change,
510 /// but doesn't contain offsets and parent pointers.
511 use rowanrust-analyzer cargo rowan 0.16.1 crate/::{GreenNoderust-analyzer cargo rowan 0.16.1 green/node/GreenNode#, GreenTokenrust-analyzer cargo rowan 0.16.1 green/token/GreenToken#};
512
513 /// You can construct GreenNodes by hand, but a builder
514 /// is helpful for top-down parsers: it maintains a stack
515 /// of currently in-progress nodes
516 use rowanrust-analyzer cargo rowan 0.16.1 crate/::GreenNodeBuilderrust-analyzer cargo rowan 0.16.1 green/builder/GreenNodeBuilder#;
517
518 /// Emit one token per character of a version constraint into an in-progress
519 /// CONSTRAINT node, matching what the lexer would have produced for the same
520 /// operator.
521 fn push_constraint_tokensrust-analyzer cargo r-description 0.4.1 lossless/relations/push_constraint_tokens().(builder: &mut GreenNodeBuilderrust-analyzer cargo rowan 0.16.1 green/builder/GreenNodeBuilder#, vc: &VersionConstraintrust-analyzer cargo r-description 0.4.1 relations/VersionConstraint#) {
522 for c in vc.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().().charsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]chars().() {
523 let kind = match c {
524 '>' => R_ANGLErust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#R_ANGLE#,
525 '<' => L_ANGLErust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#L_ANGLE#,
526 '=' => EQUALrust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#EQUAL#,
527 '!' => NOTrust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#NOT#,
528 _ => unreachablerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/unreachable!!("unexpected constraint character {c:?}"),
529 };
530 builder.tokenrust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]token().(kind.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), c.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().().as_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]as_str().());
531 }
532 }
533
534 /// The parse results are stored as a "green tree".
535 /// We'll discuss working with the results later
536 struct Parserust-analyzer cargo r-description 0.4.1 lossless/relations/Parse# {
537 green_noderust-analyzer cargo r-description 0.4.1 lossless/relations/Parse#green_node.: GreenNoderust-analyzer cargo rowan 0.16.1 green/node/GreenNode#,
538 #[allow(unused)]
539 errorsrust-analyzer cargo r-description 0.4.1 lossless/relations/Parse#errors.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>,
540 }
541
542 fn parserust-analyzer cargo r-description 0.4.1 lossless/relations/parse().(text: &str) -> Parserust-analyzer cargo r-description 0.4.1 lossless/relations/Parse# {
543 struct Parserrust-analyzer cargo r-description 0.4.1 lossless/relations/Parser# {
544 /// input tokens, including whitespace,
545 /// in *reverse* order.
546 tokensrust-analyzer cargo r-description 0.4.1 lossless/relations/Parser#tokens.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<(SyntaxKindrust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#, Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#)>,
547 /// the in-progress tree.
548 builderrust-analyzer cargo r-description 0.4.1 lossless/relations/Parser#builder.: GreenNodeBuilderrust-analyzer cargo rowan 0.16.1 green/builder/GreenNodeBuilder#<'static>,
549 /// the list of syntax errors we've accumulated
550 /// so far.
551 errorsrust-analyzer cargo r-description 0.4.1 lossless/relations/Parser#errors.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>,
552 }
553
554 impl Parserrust-analyzer cargo r-description 0.4.1 lossless/relations/Parser# {
555 fn errorrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Parser]error().(&mut self, error: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#) {
556 self.errorsrust-analyzer cargo r-description 0.4.1 lossless/relations/Parser#errors..pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(error);
557 self.builderrust-analyzer cargo r-description 0.4.1 lossless/relations/Parser#builder..start_noderust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]start_node().(SyntaxKindrust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#::ERRORrust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#ERROR#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
558 if self.currentrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Parser]current().().is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().() {
559 self.bumprust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Parser]bump().();
560 }
561 self.builderrust-analyzer cargo r-description 0.4.1 lossless/relations/Parser#builder..finish_noderust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]finish_node().();
562 }
563
564 fn parse_relationrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Parser]parse_relation().(&mut self) {
565 self.builderrust-analyzer cargo r-description 0.4.1 lossless/relations/Parser#builder..start_noderust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]start_node().(SyntaxKindrust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#::RELATIONrust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#RELATION#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
566 if self.currentrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Parser]current().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq().Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(IDENTrust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#IDENT#) {
567 self.bumprust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Parser]bump().();
568 } else {
569 self.errorrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Parser]error().("Expected package name".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().());
570 }
571 match self.peek_past_wsrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Parser]peek_past_ws().() {
572 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(COMMArust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#COMMA#) => {}
573 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(L_PARENSrust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#L_PARENS#) => {
574 self.skip_wsrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Parser]skip_ws().();
575 }
576 e => {
577 self.skip_wsrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Parser]skip_ws().();
578 self.errorrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Parser]error().(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!(
579 "Expected ':' or '|' or '[' or '<' or ',' but got {e:?}"
580 ));
581 }
582 }
583
584 if self.peek_past_wsrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Parser]peek_past_ws().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq().Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(L_PARENSrust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#L_PARENS#) {
585 self.skip_wsrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Parser]skip_ws().();
586 self.builderrust-analyzer cargo r-description 0.4.1 lossless/relations/Parser#builder..start_noderust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]start_node().(VERSIONrust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#VERSION#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
587 self.bumprust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Parser]bump().();
588 self.skip_wsrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Parser]skip_ws().();
589
590 self.builderrust-analyzer cargo r-description 0.4.1 lossless/relations/Parser#builder..start_noderust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]start_node().(CONSTRAINTrust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#CONSTRAINT#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
591
592 while self.currentrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Parser]current().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq().Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(L_ANGLErust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#L_ANGLE#)
593 || self.currentrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Parser]current().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq().Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(R_ANGLErust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#R_ANGLE#)
594 || self.currentrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Parser]current().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq().Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(EQUALrust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#EQUAL#)
595 || self.currentrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Parser]current().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq().Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(NOTrust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#NOT#)
596 {
597 self.bumprust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Parser]bump().();
598 }
599
600 self.builderrust-analyzer cargo r-description 0.4.1 lossless/relations/Parser#builder..finish_noderust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]finish_node().();
601
602 self.skip_wsrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Parser]skip_ws().();
603
604 if self.currentrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Parser]current().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq().Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(IDENTrust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#IDENT#) {
605 self.bumprust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Parser]bump().();
606 } else {
607 self.errorrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Parser]error().("Expected version".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().());
608 }
609
610 if self.currentrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Parser]current().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq().Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(R_PARENSrust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#R_PARENS#) {
611 self.bumprust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Parser]bump().();
612 } else {
613 self.errorrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Parser]error().("Expected ')'".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().());
614 }
615
616 self.builderrust-analyzer cargo r-description 0.4.1 lossless/relations/Parser#builder..finish_noderust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]finish_node().();
617 }
618
619 self.builderrust-analyzer cargo r-description 0.4.1 lossless/relations/Parser#builder..finish_noderust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]finish_node().();
620 }
621
622 fn parserust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Parser]parse().(mut self) -> Parserust-analyzer cargo r-description 0.4.1 lossless/relations/Parse# {
623 self.builderrust-analyzer cargo r-description 0.4.1 lossless/relations/Parser#builder..start_noderust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]start_node().(SyntaxKindrust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#::ROOTrust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#ROOT#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
624
625 self.skip_wsrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Parser]skip_ws().();
626
627 while self.currentrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Parser]current().().is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().() {
628 match self.currentrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Parser]current().() {
629 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(IDENTrust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#IDENT#) => self.parse_relationrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Parser]parse_relation().(),
630 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(COMMArust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#COMMA#) => {
631 // Empty relation, but that's okay - probably?
632 }
633 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(c) => {
634 self.errorrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Parser]error().(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("expected identifier or comma but got {c:?}"));
635 }
636 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => {
637 self.errorrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Parser]error().("expected identifier but got end of file".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().());
638 }
639 }
640
641 self.skip_wsrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Parser]skip_ws().();
642 match self.currentrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Parser]current().() {
643 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(COMMArust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#COMMA#) => {
644 self.bumprust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Parser]bump().();
645 }
646 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => {
647 break;
648 }
649 c => {
650 self.errorrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Parser]error().(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("expected comma or end of file but got {c:?}"));
651 }
652 }
653 self.skip_wsrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Parser]skip_ws().();
654 }
655
656 self.builderrust-analyzer cargo r-description 0.4.1 lossless/relations/Parser#builder..finish_noderust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]finish_node().();
657 // Turn the builder into a GreenNode
658 Parserust-analyzer cargo r-description 0.4.1 lossless/relations/Parse# {
659 green_noderust-analyzer cargo r-description 0.4.1 lossless/relations/Parse#green_node.: self.builderrust-analyzer cargo r-description 0.4.1 lossless/relations/Parser#builder..finishrust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]finish().(),
660 errorsrust-analyzer cargo r-description 0.4.1 lossless/relations/Parse#errors.: self.errorsrust-analyzer cargo r-description 0.4.1 lossless/relations/Parser#errors.,
661 }
662 }
663 /// Advance one token, adding it to the current branch of the tree builder.
664 fn bumprust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Parser]bump().(&mut self) {
665 let (kind, text) = self.tokensrust-analyzer cargo r-description 0.4.1 lossless/relations/Parser#tokens..poprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]pop().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().();
666 self.builderrust-analyzer cargo r-description 0.4.1 lossless/relations/Parser#builder..tokenrust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]token().(kind.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), text.as_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]as_str().());
667 }
668 /// Peek at the first unprocessed token
669 fn currentrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Parser]current().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<SyntaxKindrust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#> {
670 self.tokensrust-analyzer cargo r-description 0.4.1 lossless/relations/Parser#tokens..lastrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]last().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|(kind, _)| *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().kind)
671 }
672 fn skip_wsrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Parser]skip_ws().(&mut self) {
673 while self.currentrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Parser]current().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq().Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(WHITESPACErust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#WHITESPACE#) || self.currentrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Parser]current().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq().Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(NEWLINErust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#NEWLINE#) {
674 self.bumprust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Parser]bump().()
675 }
676 }
677
678 fn peek_past_wsrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Parser]peek_past_ws().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<SyntaxKindrust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#> {
679 let mut i = self.tokensrust-analyzer cargo r-description 0.4.1 lossless/relations/Parser#tokens..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().();
680 while i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().0 {
681 i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign().-=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign().1;
682 match self.tokensrust-analyzer cargo r-description 0.4.1 lossless/relations/Parser#tokens.[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().i]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()..0 {
683 WHITESPACErust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#WHITESPACE# | NEWLINErust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#NEWLINE# => {}
684 _ => return Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(self.tokensrust-analyzer cargo r-description 0.4.1 lossless/relations/Parser#tokens.[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().i]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()..0),
685 }
686 }
687 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#
688 }
689 }
690
691 let mut tokens = craterust-analyzer cargo r-description 0.4.1 crate/::relationsrust-analyzer cargo r-description 0.4.1 relations/::lexrust-analyzer cargo r-description 0.4.1 relations/lex().(text);
692 tokens.reverserust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]reverse().();
693 Parserrust-analyzer cargo r-description 0.4.1 lossless/relations/Parser# {
694 tokensrust-analyzer cargo r-description 0.4.1 lossless/relations/Parser#tokens.,
695 builderrust-analyzer cargo r-description 0.4.1 lossless/relations/Parser#builder.: GreenNodeBuilderrust-analyzer cargo rowan 0.16.1 green/builder/GreenNodeBuilder#::newrust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]new().(),
696 errorsrust-analyzer cargo r-description 0.4.1 lossless/relations/Parser#errors.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().(),
697 }
698 .parserust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Parser]parse().()
699 }
700
701 /// To work with the parse results we need a view into the
702 /// green tree - the Syntax tree.
703 /// It is also immutable, like a GreenNode,
704 /// but it contains parent pointers, offsets, and
705 /// has identity semantics.
706 type SyntaxNoderust-analyzer cargo r-description 0.4.1 lossless/relations/SyntaxNode# = rowanrust-analyzer cargo rowan 0.16.1 crate/::SyntaxNoderust-analyzer cargo rowan 0.16.1 api/SyntaxNode#<Langrust-analyzer cargo r-description 0.4.1 lossless/relations/Lang#>;
707 #[allow(unused)]
708 type SyntaxTokenrust-analyzer cargo r-description 0.4.1 lossless/relations/SyntaxToken# = rowanrust-analyzer cargo rowan 0.16.1 crate/::SyntaxTokenrust-analyzer cargo rowan 0.16.1 api/SyntaxToken#<Langrust-analyzer cargo r-description 0.4.1 lossless/relations/Lang#>;
709 #[allow(unused)]
710 type SyntaxElementrust-analyzer cargo r-description 0.4.1 lossless/relations/SyntaxElement# = rowanrust-analyzer cargo rowan 0.16.1 crate/::NodeOrTokenrust-analyzer cargo rowan 0.16.1 utility_types/NodeOrToken#<SyntaxNoderust-analyzer cargo r-description 0.4.1 lossless/relations/SyntaxNode#, SyntaxTokenrust-analyzer cargo r-description 0.4.1 lossless/relations/SyntaxToken#>;
711
712 impl Parserust-analyzer cargo r-description 0.4.1 lossless/relations/Parse# {
713 fn root_mutrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Parse]root_mut().(&self) -> Relationsrust-analyzer cargo r-description 0.4.1 lossless/relations/Relations# {
714 Relationsrust-analyzer cargo r-description 0.4.1 lossless/relations/Relations#::castrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relations]cast().(SyntaxNoderust-analyzer cargo r-description 0.4.1 lossless/relations/SyntaxNode#::new_root_mutrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]new_root_mut().(self.green_noderust-analyzer cargo r-description 0.4.1 lossless/relations/Parse#green_node..clonerust-analyzer cargo rowan 0.16.1 green/node/impl#[GreenNode][Clone]clone().())).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().()
715 }
716 }
717
718 macro_rules! ast_noderust-analyzer cargo r-description 0.4.1 lossless/relations/ast_node! {
719 ($ast:ident, $kind:ident) => {
720 /// A node in the syntax tree representing a $ast
721 #[repr(transparent)]
722 pub struct $ast(SyntaxNode);
723 impl $ast {
724 #[allow(unused)]
725 fn cast(node: SyntaxNode) -> Option<Self> {
726 if node.kind() == $kind {
727 Some(Self(node))
728 } else {
729 None
730 }
731 }
732 }
733
734 impl std::fmt::Display for $ast {
735 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
736 f.write_str(&self.0.text().to_string())
737 }
738 }
739 };
740 }
741
742 ast_noderust-analyzer cargo r-description 0.4.1 lossless/relations/ast_node!!(Relationsrust-analyzer cargo r-description 0.4.1 lossless/relations/Relations#, ROOTrust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#ROOT#);
743 ast_noderust-analyzer cargo r-description 0.4.1 lossless/relations/ast_node!!(Relationrust-analyzer cargo r-description 0.4.1 lossless/relations/Relation#, RELATIONrust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#RELATION#);
744
745 impl PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq# for Relationsrust-analyzer cargo r-description 0.4.1 lossless/relations/Relations# {
746 fn eqrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relations][`PartialEq<Self>`]eq().(&self, other: &Selfrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relations][`PartialEq<Self>`]) -> bool {
747 self.relationsrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relations]relations().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_>>() rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/partial_eq/impl#[`Vec<T, A1>`][`PartialEq<Vec<U, A2>>`]eq().==rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/partial_eq/impl#[`Vec<T, A1>`][`PartialEq<Vec<U, A2>>`]eq(). rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/partial_eq/impl#[`Vec<T, A1>`][`PartialEq<Vec<U, A2>>`]eq().other.relationsrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relations]relations().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_>>()
748 }
749 }
750
751 impl PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq# for Relationrust-analyzer cargo r-description 0.4.1 lossless/relations/Relation# {
752 fn eqrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relation][`PartialEq<Self>`]eq().(&self, other: &Selfrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relation][`PartialEq<Self>`]) -> bool {
753 self.namerust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relation]name().() rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`PartialEq<Self>`]eq().==rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`PartialEq<Self>`]eq(). rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`PartialEq<Self>`]eq().other.namerust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relation]name().() && self.versionrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relation]version().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq().other.versionrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relation]version().()
754 }
755 }
756
757 #[cfg(feature = "serde")]
758 impl serderust-analyzer cargo serde 1.0.229 crate/::Serializerust-analyzer cargo serde_core 1.0.229 ser/Serialize# for Relationsrust-analyzer cargo r-description 0.4.1 lossless/relations/Relations# {
759 fn serializerust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relations][Serialize]serialize().<S: serderust-analyzer cargo serde 1.0.229 crate/::Serializerrust-analyzer cargo serde_core 1.0.229 ser/Serializer#>(&self, serializer: S) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<S::Okrust-analyzer cargo serde_core 1.0.229 ser/Serializer#Ok#, S::Errorrust-analyzer cargo serde_core 1.0.229 ser/Serializer#Error#> {
760 let rep = self.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().();
761 serializer.serialize_strrust-analyzer cargo serde_core 1.0.229 ser/Serializer#serialize_str().(&rep)
762 }
763 }
764
765 #[cfg(feature = "serde")]
766 impl<'de> serderust-analyzer cargo serde 1.0.229 crate/::Deserializerust-analyzer cargo serde_core 1.0.229 de/Deserialize#<'de> for Relationsrust-analyzer cargo r-description 0.4.1 lossless/relations/Relations# {
767 fn deserializerust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relations][`Deserialize<'de>`]deserialize().<D: serderust-analyzer cargo serde 1.0.229 crate/::Deserializerrust-analyzer cargo serde_core 1.0.229 de/Deserializer#<'de>>(deserializer: D) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relations][`Deserialize<'de>`], D::Errorrust-analyzer cargo serde_core 1.0.229 de/Deserializer#Error#> {
768 let s = Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::deserializerust-analyzer cargo serde_core 1.0.229 de/impls/impl#[String][`Deserialize<'de>`]deserialize().(deserializer)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
769 let relations = s.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(serderust-analyzer cargo serde 1.0.229 crate/::derust-analyzer cargo serde_core 1.0.229 de/::Errorrust-analyzer cargo serde_core 1.0.229 de/Error#::customrust-analyzer cargo serde_core 1.0.229 de/Error#custom().)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/try_trait/Try#branch().;
770 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(relations)
771 }
772 }
773
774 impl 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/::Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug# for Relationsrust-analyzer cargo r-description 0.4.1 lossless/relations/Relations# {
775 fn fmtrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relations][Debug]fmt().(&self, f: &mut 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/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#<'_>) -> 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/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# {
776 let mut s = f.debug_structrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/impl#[`Formatter<'a>`]debug_struct().("Relations");
777
778 for relation in self.relationsrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relations]relations().() {
779 s.fieldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]field().("relation", &relation);
780 }
781
782 s.finishrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]finish().()
783 }
784 }
785
786 impl 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/::Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug# for Relationrust-analyzer cargo r-description 0.4.1 lossless/relations/Relation# {
787 fn fmtrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relation][Debug]fmt().(&self, f: &mut 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/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#<'_>) -> 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/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# {
788 let mut s = f.debug_structrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/impl#[`Formatter<'a>`]debug_struct().("Relation");
789
790 s.fieldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]field().("name", &self.namerust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relation]name().());
791
792 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((vc, version)) = self.versionrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relation]version().() {
793 s.fieldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]field().("version", &vc);
794 s.fieldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]field().("version", &version);
795 }
796
797 s.finishrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]finish().()
798 }
799 }
800
801 #[cfg(feature = "serde")]
802 impl serderust-analyzer cargo serde 1.0.229 crate/::Serializerust-analyzer cargo serde_core 1.0.229 ser/Serialize# for Relationrust-analyzer cargo r-description 0.4.1 lossless/relations/Relation# {
803 fn serializerust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relation][Serialize]serialize().<S: serderust-analyzer cargo serde 1.0.229 crate/::Serializerrust-analyzer cargo serde_core 1.0.229 ser/Serializer#>(&self, serializer: S) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<S::Okrust-analyzer cargo serde_core 1.0.229 ser/Serializer#Ok#, S::Errorrust-analyzer cargo serde_core 1.0.229 ser/Serializer#Error#> {
804 let rep = self.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().();
805 serializer.serialize_strrust-analyzer cargo serde_core 1.0.229 ser/Serializer#serialize_str().(&rep)
806 }
807 }
808
809 #[cfg(feature = "serde")]
810 impl<'de> serderust-analyzer cargo serde 1.0.229 crate/::Deserializerust-analyzer cargo serde_core 1.0.229 de/Deserialize#<'de> for Relationrust-analyzer cargo r-description 0.4.1 lossless/relations/Relation# {
811 fn deserializerust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relation][`Deserialize<'de>`]deserialize().<D: serderust-analyzer cargo serde 1.0.229 crate/::Deserializerrust-analyzer cargo serde_core 1.0.229 de/Deserializer#<'de>>(deserializer: D) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relation][`Deserialize<'de>`], D::Errorrust-analyzer cargo serde_core 1.0.229 de/Deserializer#Error#> {
812 let s = Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::deserializerust-analyzer cargo serde_core 1.0.229 de/impls/impl#[String][`Deserialize<'de>`]deserialize().(deserializer)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
813 let relation = s.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(serderust-analyzer cargo serde 1.0.229 crate/::derust-analyzer cargo serde_core 1.0.229 de/::Errorrust-analyzer cargo serde_core 1.0.229 de/Error#::customrust-analyzer cargo serde_core 1.0.229 de/Error#custom().)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/try_trait/Try#branch().;
814 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(relation)
815 }
816 }
817
818 impl Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default# for Relationsrust-analyzer cargo r-description 0.4.1 lossless/relations/Relations# {
819 fn defaultrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relations][Default]default().() -> Selfrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relations][Default] {
820 Selfrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relations][Default]::newrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relations]new().()
821 }
822 }
823
824 impl Relationsrust-analyzer cargo r-description 0.4.1 lossless/relations/Relations# {
825 /// Create a new relations field
826 pub fn newrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relations]new().() -> Selfrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relations] {
827 Selfrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relations]::fromrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relations][`From<Vec<Relation>>`]from().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![])
828 }
829
830 /// Wrap and sort this relations field
831 #[must_use]
832 pub fn wrap_and_sortrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relations]wrap_and_sort().(self) -> Selfrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relations] {
833 let mut entries = self
834 .relationsrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relations]relations().()
835 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|e| e.wrap_and_sortrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relation]wrap_and_sort().())
836 .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_>>();
837 entries.sortrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]sort().();
838 // TODO: preserve comments
839 Selfrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relations]::fromrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relations][`From<Vec<Relation>>`]from().(entries)
840 }
841
842 /// Iterate over the entries in this relations field
843 pub fn relationsrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relations]relations().(&self) -> impl Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item# = Relationrust-analyzer cargo r-description 0.4.1 lossless/relations/Relation#> + '_ {
844 self.0rust-analyzer cargo r-description 0.4.1 lossless/relations/Relations#0..childrenrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]children().().filter_maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#filter_map().(Relationrust-analyzer cargo r-description 0.4.1 lossless/relations/Relation#::castrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relation]cast().)
845 }
846
847 /// Iterate over the entries in this relations field
848 pub fn iterrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relations]iter().(&self) -> impl Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item# = Relationrust-analyzer cargo r-description 0.4.1 lossless/relations/Relation#> + '_ {
849 self.relationsrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relations]relations().()
850 }
851
852 /// Remove the entry at the given index
853 pub fn get_relationrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relations]get_relation().(&self, idx: usize) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Relationrust-analyzer cargo r-description 0.4.1 lossless/relations/Relation#> {
854 self.relationsrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relations]relations().().nthrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#nth().(idx)
855 }
856
857 /// Remove the relation at the given index
858 pub fn remove_relationrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relations]remove_relation().(&mut self, idx: usize) -> Relationrust-analyzer cargo r-description 0.4.1 lossless/relations/Relation# {
859 let mut relation = self.get_relationrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relations]get_relation().(idx).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().();
860 relation.removerust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relation]remove().();
861 relation
862 }
863
864 /// Insert a new relation at the given index
865 pub fn insertrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relations]insert().(&mut self, idx: usize, relation: Relationrust-analyzer cargo r-description 0.4.1 lossless/relations/Relation#) {
866 let is_empty = !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().self.0rust-analyzer cargo r-description 0.4.1 lossless/relations/Relations#0..children_with_tokensrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]children_with_tokens().().anyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#any().(|n| n.kindrust-analyzer cargo rowan 0.16.1 api/impl#[`NodeOrToken<SyntaxNode<L>, SyntaxToken<L>>`]kind().() rust-analyzer cargo r-description 0.4.1 relations/impl#[SyntaxKind][`PartialEq<Self>`]eq().==rust-analyzer cargo r-description 0.4.1 relations/impl#[SyntaxKind][`PartialEq<Self>`]eq(). rust-analyzer cargo r-description 0.4.1 relations/impl#[SyntaxKind][`PartialEq<Self>`]eq().COMMArust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#COMMA#);
867 let (position, new_children) = if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(current_relation) = self.relationsrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relations]relations().().nthrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#nth().(idx)
868 {
869 let to_insert: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<NodeOrTokenrust-analyzer cargo rowan 0.16.1 utility_types/NodeOrToken#<GreenNoderust-analyzer cargo rowan 0.16.1 green/node/GreenNode#, GreenTokenrust-analyzer cargo rowan 0.16.1 green/token/GreenToken#>> = if idx rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().0 && is_empty {
870 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![relation.0rust-analyzer cargo r-description 0.4.1 lossless/relations/Relation#0..greenrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]green().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()]
871 } else {
872 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![
873 relation.0rust-analyzer cargo r-description 0.4.1 lossless/relations/Relation#0..greenrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]green().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(),
874 NodeOrTokenrust-analyzer cargo rowan 0.16.1 utility_types/NodeOrToken#::Tokenrust-analyzer cargo rowan 0.16.1 utility_types/NodeOrToken#Token#(GreenTokenrust-analyzer cargo rowan 0.16.1 green/token/GreenToken#::newrust-analyzer cargo rowan 0.16.1 green/token/impl#[GreenToken]new().(COMMArust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#COMMA#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), ",")),
875 NodeOrTokenrust-analyzer cargo rowan 0.16.1 utility_types/NodeOrToken#::Tokenrust-analyzer cargo rowan 0.16.1 utility_types/NodeOrToken#Token#(GreenTokenrust-analyzer cargo rowan 0.16.1 green/token/GreenToken#::newrust-analyzer cargo rowan 0.16.1 green/token/impl#[GreenToken]new().(WHITESPACErust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#WHITESPACE#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), " ")),
876 ]
877 };
878
879 (current_relation.0rust-analyzer cargo r-description 0.4.1 lossless/relations/Relation#0..indexrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]index().(), to_insert)
880 } else {
881 let child_count = self.0rust-analyzer cargo r-description 0.4.1 lossless/relations/Relations#0..children_with_tokensrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]children_with_tokens().().countrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#count().();
882 (
883 child_count,
884 if idx rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().0 {
885 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![relation.0rust-analyzer cargo r-description 0.4.1 lossless/relations/Relation#0..greenrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]green().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()]
886 } else {
887 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![
888 NodeOrTokenrust-analyzer cargo rowan 0.16.1 utility_types/NodeOrToken#::Tokenrust-analyzer cargo rowan 0.16.1 utility_types/NodeOrToken#Token#(GreenTokenrust-analyzer cargo rowan 0.16.1 green/token/GreenToken#::newrust-analyzer cargo rowan 0.16.1 green/token/impl#[GreenToken]new().(COMMArust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#COMMA#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), ",")),
889 NodeOrTokenrust-analyzer cargo rowan 0.16.1 utility_types/NodeOrToken#::Tokenrust-analyzer cargo rowan 0.16.1 utility_types/NodeOrToken#Token#(GreenTokenrust-analyzer cargo rowan 0.16.1 green/token/GreenToken#::newrust-analyzer cargo rowan 0.16.1 green/token/impl#[GreenToken]new().(WHITESPACErust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#WHITESPACE#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), " ")),
890 relation.0rust-analyzer cargo r-description 0.4.1 lossless/relations/Relation#0..greenrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]green().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(),
891 ]
892 },
893 )
894 };
895 // We can safely replace the root here since Relations is a root node
896 self.0rust-analyzer cargo r-description 0.4.1 lossless/relations/Relations#0. = SyntaxNoderust-analyzer cargo r-description 0.4.1 lossless/relations/SyntaxNode#::new_root_mutrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]new_root_mut().(
897 self.0rust-analyzer cargo r-description 0.4.1 lossless/relations/Relations#0..replace_withrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]replace_with().(
898 self.0rust-analyzer cargo r-description 0.4.1 lossless/relations/Relations#0.
899 .greenrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]green().()
900 .splice_childrenrust-analyzer cargo rowan 0.16.1 green/node/impl#[GreenNodeData]splice_children().(position..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#position, new_children),
901 ),
902 );
903 }
904
905 /// Replace the relation at the given index
906 pub fn replacerust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relations]replace().(&mut self, idx: usize, relation: Relationrust-analyzer cargo r-description 0.4.1 lossless/relations/Relation#) {
907 let current_relation = self.get_relationrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relations]get_relation().(idx).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().();
908 self.0rust-analyzer cargo r-description 0.4.1 lossless/relations/Relations#0..splice_childrenrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]splice_children().(
909 current_relation.0rust-analyzer cargo r-description 0.4.1 lossless/relations/Relation#0..indexrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]index().()..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#current_relation.0rust-analyzer cargo r-description 0.4.1 lossless/relations/Relation#0..indexrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]index().() 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,
910 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![relation.0rust-analyzer cargo r-description 0.4.1 lossless/relations/Relation#0..intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()],
911 );
912 }
913
914 /// Push a new relation to the relations field
915 pub fn pushrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relations]push().(&mut self, relation: Relationrust-analyzer cargo r-description 0.4.1 lossless/relations/Relation#) {
916 let pos = self.relationsrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relations]relations().().countrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#count().();
917 self.insertrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relations]insert().(pos, relation);
918 }
919
920 /// Parse a relations field from a string, allowing syntax errors
921 pub fn parse_relaxedrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relations]parse_relaxed().(s: &str) -> (Relationsrust-analyzer cargo r-description 0.4.1 lossless/relations/Relations#, Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>) {
922 let parse = parserust-analyzer cargo r-description 0.4.1 lossless/relations/parse().(s);
923 (parse.root_mutrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Parse]root_mut().(), parse.errorsrust-analyzer cargo r-description 0.4.1 lossless/relations/Parse#errors.)
924 }
925
926 /// Check if this relations field is satisfied by the given package versions.
927 pub fn satisfied_byrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relations]satisfied_by().(
928 &self,
929 package_version: impl craterust-analyzer cargo r-description 0.4.1 crate/::relationsrust-analyzer cargo r-description 0.4.1 relations/::VersionLookuprust-analyzer cargo r-description 0.4.1 relations/VersionLookup# + Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy#,
930 ) -> bool {
931 self.relationsrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relations]relations().().allrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#all().(|e| e.satisfied_byrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relation]satisfied_by().(package_version))
932 }
933
934 /// Check if this relations field is empty
935 pub fn is_emptyrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relations]is_empty().(&self) -> bool {
936 self.relationsrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relations]relations().().countrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#count().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().0
937 }
938
939 /// Get the number of entries in this relations field
940 pub fn lenrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relations]len().(&self) -> usize {
941 self.relationsrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relations]relations().().countrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#count().()
942 }
943 }
944
945 impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Relationrust-analyzer cargo r-description 0.4.1 lossless/relations/Relation#>> for Relationsrust-analyzer cargo r-description 0.4.1 lossless/relations/Relations# {
946 fn fromrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relations][`From<Vec<Relation>>`]from().(entries: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Relationrust-analyzer cargo r-description 0.4.1 lossless/relations/Relation#>) -> Selfrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relations][`From<Vec<Relation>>`] {
947 let mut builder = GreenNodeBuilderrust-analyzer cargo rowan 0.16.1 green/builder/GreenNodeBuilder#::newrust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]new().();
948 builder.start_noderust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]start_node().(ROOTrust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#ROOT#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
949 for (i, relation) in entries.into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().().enumeraterust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#enumerate().() {
950 if i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().0 {
951 builder.tokenrust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]token().(COMMArust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#COMMA#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), ",");
952 builder.tokenrust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]token().(WHITESPACErust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#WHITESPACE#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), " ");
953 }
954 injectrust-analyzer cargo r-description 0.4.1 lossless/relations/inject().(&mut builder, relation.0rust-analyzer cargo r-description 0.4.1 lossless/relations/Relation#0.);
955 }
956 builder.finish_noderust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]finish_node().();
957 Relationsrust-analyzer cargo r-description 0.4.1 lossless/relations/Relations#(SyntaxNoderust-analyzer cargo r-description 0.4.1 lossless/relations/SyntaxNode#::new_root_mutrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]new_root_mut().(builder.finishrust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]finish().()))
958 }
959 }
960
961 impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<Relationrust-analyzer cargo r-description 0.4.1 lossless/relations/Relation#> for Relationsrust-analyzer cargo r-description 0.4.1 lossless/relations/Relations# {
962 fn fromrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relations][`From<Relation>`]from().(relation: Relationrust-analyzer cargo r-description 0.4.1 lossless/relations/Relation#) -> Selfrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relations][`From<Relation>`] {
963 Selfrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relations][`From<Relation>`]::fromrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relations][`From<Vec<Relation>>`]from().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![relation])
964 }
965 }
966
967 impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<Relationrust-analyzer cargo r-description 0.4.1 lossless/relations/Relation#> for craterust-analyzer cargo r-description 0.4.1 crate/::lossyrust-analyzer cargo r-description 0.4.1 lossy/::Relationrust-analyzer cargo r-description 0.4.1 lossy/Relation# {
968 fn fromrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[`crate::lossy::Relation`][`From<Relation>`]from().(relation: Relationrust-analyzer cargo r-description 0.4.1 lossless/relations/Relation#) -> Selfrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[`crate::lossy::Relation`][`From<Relation>`] {
969 let mut rel = craterust-analyzer cargo r-description 0.4.1 crate/::lossyrust-analyzer cargo r-description 0.4.1 lossy/::Relationrust-analyzer cargo r-description 0.4.1 lossy/Relation#::newrust-analyzer cargo r-description 0.4.1 lossy/impl#[Relation]new().();
970 rel.namerust-analyzer cargo r-description 0.4.1 lossy/Relation#name. = relation.namerust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relation]name().();
971 rel.versionrust-analyzer cargo r-description 0.4.1 lossy/Relation#version. = relation
972 .versionrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relation]version().()
973 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|(constraint, version)| (constraint, version.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()));
974 rel
975 }
976 }
977
978 impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<Relationsrust-analyzer cargo r-description 0.4.1 lossless/relations/Relations#> for craterust-analyzer cargo r-description 0.4.1 crate/::lossyrust-analyzer cargo r-description 0.4.1 lossy/::Relationsrust-analyzer cargo r-description 0.4.1 lossy/Relations# {
979 fn fromrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[`crate::lossy::Relations`][`From<Relations>`]from().(relations: Relationsrust-analyzer cargo r-description 0.4.1 lossless/relations/Relations#) -> Selfrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[`crate::lossy::Relations`][`From<Relations>`] {
980 let mut rels = craterust-analyzer cargo r-description 0.4.1 crate/::lossyrust-analyzer cargo r-description 0.4.1 lossy/::Relationsrust-analyzer cargo r-description 0.4.1 lossy/Relations#::newrust-analyzer cargo r-description 0.4.1 lossy/impl#[Relations]new().();
981 for relation in relations.relationsrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relations]relations().() {
982 rels.0rust-analyzer cargo r-description 0.4.1 lossy/Relations#0..pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(relation.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
983 }
984 rels
985 }
986 }
987
988 impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<craterust-analyzer cargo r-description 0.4.1 crate/::lossyrust-analyzer cargo r-description 0.4.1 lossy/::Relationsrust-analyzer cargo r-description 0.4.1 lossy/Relations#> for Relationsrust-analyzer cargo r-description 0.4.1 lossless/relations/Relations# {
989 fn fromrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relations][`From<crate::lossy::Relations>`]from().(relations: craterust-analyzer cargo r-description 0.4.1 crate/::lossyrust-analyzer cargo r-description 0.4.1 lossy/::Relationsrust-analyzer cargo r-description 0.4.1 lossy/Relations#) -> Selfrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relations][`From<crate::lossy::Relations>`] {
990 let mut entries = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![];
991 for relation in relations.iterrust-analyzer cargo r-description 0.4.1 lossy/impl#[Relations]iter().() {
992 entries.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(relation.clonerust-analyzer cargo r-description 0.4.1 lossy/impl#[Relation][Clone]clone().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
993 }
994 Selfrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relations][`From<crate::lossy::Relations>`]::fromrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relations][`From<Vec<Relation>>`]from().(entries)
995 }
996 }
997
998 impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<craterust-analyzer cargo r-description 0.4.1 crate/::lossyrust-analyzer cargo r-description 0.4.1 lossy/::Relationrust-analyzer cargo r-description 0.4.1 lossy/Relation#> for Relationrust-analyzer cargo r-description 0.4.1 lossless/relations/Relation# {
999 fn fromrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relation][`From<crate::lossy::Relation>`]from().(relation: craterust-analyzer cargo r-description 0.4.1 crate/::lossyrust-analyzer cargo r-description 0.4.1 lossy/::Relationrust-analyzer cargo r-description 0.4.1 lossy/Relation#) -> Selfrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relation][`From<crate::lossy::Relation>`] {
1000 Relationrust-analyzer cargo r-description 0.4.1 lossless/relations/Relation#::newrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relation]new().(
1001 &relation.namerust-analyzer cargo r-description 0.4.1 lossy/Relation#name.,
1002 relation
1003 .versionrust-analyzer cargo r-description 0.4.1 lossy/Relation#version.
1004 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|(constraint, version)| (constraint, version.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().())),
1005 )
1006 }
1007 }
1008
1009 fn injectrust-analyzer cargo r-description 0.4.1 lossless/relations/inject().(builder: &mut GreenNodeBuilderrust-analyzer cargo rowan 0.16.1 green/builder/GreenNodeBuilder#, node: SyntaxNoderust-analyzer cargo r-description 0.4.1 lossless/relations/SyntaxNode#) {
1010 builder.start_noderust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]start_node().(node.kindrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]kind().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
1011 for child in node.children_with_tokensrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]children_with_tokens().() {
1012 match child {
1013 rowanrust-analyzer cargo rowan 0.16.1 crate/::NodeOrTokenrust-analyzer cargo rowan 0.16.1 utility_types/NodeOrToken#::Noderust-analyzer cargo rowan 0.16.1 utility_types/NodeOrToken#Node#(child) => {
1014 injectrust-analyzer cargo r-description 0.4.1 lossless/relations/inject().(builder, child);
1015 }
1016 rowanrust-analyzer cargo rowan 0.16.1 crate/::NodeOrTokenrust-analyzer cargo rowan 0.16.1 utility_types/NodeOrToken#::Tokenrust-analyzer cargo rowan 0.16.1 utility_types/NodeOrToken#Token#(token) => {
1017 builder.tokenrust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]token().(token.kindrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxToken<L>`]kind().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), token.textrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxToken<L>`]text().());
1018 }
1019 }
1020 }
1021 builder.finish_noderust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]finish_node().();
1022 }
1023
1024 impl Relationrust-analyzer cargo r-description 0.4.1 lossless/relations/Relation# {
1025 /// Create a new relation
1026 ///
1027 /// # Arguments
1028 /// * `name` - The name of the package
1029 /// * `version_constraint` - The version constraint and version to use
1030 ///
1031 /// # Example
1032 /// ```
1033 /// use r_description::lossless::{Relation};
1034 /// use r_description::VersionConstraint;
1035 /// let relation = Relation::new("vign", Some((VersionConstraint::GreaterThanEqual, "2.0".parse().unwrap())));
1036 /// assert_eq!(relation.to_string(), "vign (>= 2.0)");
1037 /// ```
1038 pub fn newrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relation]new().(name: &str, version_constraint: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<(VersionConstraintrust-analyzer cargo r-description 0.4.1 relations/VersionConstraint#, Versionrust-analyzer cargo r-description 0.4.1 lossless/relations/Version#)>) -> Selfrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relation] {
1039 let mut builder = GreenNodeBuilderrust-analyzer cargo rowan 0.16.1 green/builder/GreenNodeBuilder#::newrust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]new().();
1040 builder.start_noderust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]start_node().(SyntaxKindrust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#::RELATIONrust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#RELATION#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
1041 builder.tokenrust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]token().(IDENTrust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#IDENT#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), name);
1042 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((vc, version)) = version_constraint {
1043 builder.tokenrust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]token().(WHITESPACErust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#WHITESPACE#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), " ");
1044 builder.start_noderust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]start_node().(SyntaxKindrust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#::VERSIONrust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#VERSION#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
1045 builder.tokenrust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]token().(L_PARENSrust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#L_PARENS#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), "(");
1046 builder.start_noderust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]start_node().(SyntaxKindrust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#::CONSTRAINTrust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#CONSTRAINT#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
1047 push_constraint_tokensrust-analyzer cargo r-description 0.4.1 lossless/relations/push_constraint_tokens().(&mut builder, &vc);
1048 builder.finish_noderust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]finish_node().();
1049
1050 builder.tokenrust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]token().(WHITESPACErust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#WHITESPACE#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), " ");
1051
1052 builder.tokenrust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]token().(IDENTrust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#IDENT#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), version.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().().as_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]as_str().());
1053
1054 builder.tokenrust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]token().(R_PARENSrust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#R_PARENS#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), ")");
1055
1056 builder.finish_noderust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]finish_node().();
1057 }
1058
1059 builder.finish_noderust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]finish_node().();
1060 Relationrust-analyzer cargo r-description 0.4.1 lossless/relations/Relation#(SyntaxNoderust-analyzer cargo r-description 0.4.1 lossless/relations/SyntaxNode#::new_root_mutrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]new_root_mut().(builder.finishrust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]finish().()))
1061 }
1062
1063 /// Wrap and sort this relation
1064 ///
1065 /// # Example
1066 /// ```
1067 /// use r_description::lossless::Relation;
1068 /// let relation = " vign ( >= 2.0) ".parse::<Relation>().unwrap();
1069 /// assert_eq!(relation.wrap_and_sort().to_string(), "vign (>= 2.0)");
1070 /// ```
1071 #[must_use]
1072 pub fn wrap_and_sortrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relation]wrap_and_sort().(&self) -> Selfrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relation] {
1073 let mut builder = GreenNodeBuilderrust-analyzer cargo rowan 0.16.1 green/builder/GreenNodeBuilder#::newrust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]new().();
1074 builder.start_noderust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]start_node().(SyntaxKindrust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#::RELATIONrust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#RELATION#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
1075 builder.tokenrust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]token().(IDENTrust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#IDENT#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), self.namerust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relation]name().().as_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]as_str().());
1076 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((vc, version)) = self.versionrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relation]version().() {
1077 builder.tokenrust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]token().(WHITESPACErust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#WHITESPACE#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), " ");
1078 builder.start_noderust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]start_node().(SyntaxKindrust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#::VERSIONrust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#VERSION#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
1079 builder.tokenrust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]token().(L_PARENSrust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#L_PARENS#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), "(");
1080 builder.start_noderust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]start_node().(SyntaxKindrust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#::CONSTRAINTrust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#CONSTRAINT#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
1081 push_constraint_tokensrust-analyzer cargo r-description 0.4.1 lossless/relations/push_constraint_tokens().(&mut builder, &vc);
1082 builder.finish_noderust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]finish_node().();
1083 builder.tokenrust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]token().(WHITESPACErust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#WHITESPACE#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), " ");
1084 builder.tokenrust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]token().(IDENTrust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#IDENT#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), version.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().().as_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]as_str().());
1085 builder.tokenrust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]token().(R_PARENSrust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#R_PARENS#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), ")");
1086 builder.finish_noderust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]finish_node().();
1087 }
1088 builder.finish_noderust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]finish_node().();
1089 Relationrust-analyzer cargo r-description 0.4.1 lossless/relations/Relation#(SyntaxNoderust-analyzer cargo r-description 0.4.1 lossless/relations/SyntaxNode#::new_root_mutrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]new_root_mut().(builder.finishrust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]finish().()))
1090 }
1091
1092 /// Create a new simple relation, without any version constraints.
1093 ///
1094 /// # Example
1095 /// ```
1096 /// use r_description::lossless::Relation;
1097 /// let relation = Relation::simple("vign");
1098 /// assert_eq!(relation.to_string(), "vign");
1099 /// ```
1100 pub fn simplerust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relation]simple().(name: &str) -> Selfrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relation] {
1101 Selfrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relation]::newrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relation]new().(name, Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#)
1102 }
1103
1104 /// Remove the version constraint from the relation.
1105 ///
1106 /// # Example
1107 /// ```
1108 /// use r_description::lossless::{Relation};
1109 /// use r_description::VersionConstraint;
1110 /// let mut relation = Relation::new("vign", Some((VersionConstraint::GreaterThanEqual, "2.0".parse().unwrap())));
1111 /// relation.drop_constraint();
1112 /// assert_eq!(relation.to_string(), "vign");
1113 /// ```
1114 pub fn drop_constraintrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relation]drop_constraint().(&mut self) -> bool {
1115 let version_token = self.0rust-analyzer cargo r-description 0.4.1 lossless/relations/Relation#0..childrenrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]children().().findrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#find().(|n| n.kindrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]kind().() rust-analyzer cargo r-description 0.4.1 relations/impl#[SyntaxKind][`PartialEq<Self>`]eq().==rust-analyzer cargo r-description 0.4.1 relations/impl#[SyntaxKind][`PartialEq<Self>`]eq(). rust-analyzer cargo r-description 0.4.1 relations/impl#[SyntaxKind][`PartialEq<Self>`]eq().VERSIONrust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#VERSION#);
1116 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(version_token) = version_token {
1117 // Remove any whitespace before the version token
1118 while let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(prev) = version_token.prev_sibling_or_tokenrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]prev_sibling_or_token().() {
1119 if prev.kindrust-analyzer cargo rowan 0.16.1 api/impl#[`NodeOrToken<SyntaxNode<L>, SyntaxToken<L>>`]kind().() rust-analyzer cargo r-description 0.4.1 relations/impl#[SyntaxKind][`PartialEq<Self>`]eq().==rust-analyzer cargo r-description 0.4.1 relations/impl#[SyntaxKind][`PartialEq<Self>`]eq(). rust-analyzer cargo r-description 0.4.1 relations/impl#[SyntaxKind][`PartialEq<Self>`]eq().WHITESPACErust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#WHITESPACE# || prev.kindrust-analyzer cargo rowan 0.16.1 api/impl#[`NodeOrToken<SyntaxNode<L>, SyntaxToken<L>>`]kind().() rust-analyzer cargo r-description 0.4.1 relations/impl#[SyntaxKind][`PartialEq<Self>`]eq().==rust-analyzer cargo r-description 0.4.1 relations/impl#[SyntaxKind][`PartialEq<Self>`]eq(). rust-analyzer cargo r-description 0.4.1 relations/impl#[SyntaxKind][`PartialEq<Self>`]eq().NEWLINErust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#NEWLINE# {
1120 prev.detachrust-analyzer cargo rowan 0.16.1 api/impl#[`NodeOrToken<SyntaxNode<L>, SyntaxToken<L>>`]detach().();
1121 } else {
1122 break;
1123 }
1124 }
1125 version_token.detachrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]detach().();
1126 return true;
1127 }
1128
1129 false
1130 }
1131
1132 /// Return the name of the package in the relation.
1133 ///
1134 /// # Example
1135 /// ```
1136 /// use r_description::lossless::Relation;
1137 /// let relation = Relation::simple("vign");
1138 /// assert_eq!(relation.name(), "vign");
1139 /// ```
1140 pub fn namerust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relation]name().(&self) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# {
1141 self.0rust-analyzer cargo r-description 0.4.1 lossless/relations/Relation#0.
1142 .children_with_tokensrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]children_with_tokens().()
1143 .find_maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#find_map().(|it| match it {
1144 SyntaxElementrust-analyzer cargo r-description 0.4.1 lossless/relations/SyntaxElement#::Tokenrust-analyzer cargo rowan 0.16.1 utility_types/NodeOrToken#Token#(token) if token.kindrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxToken<L>`]kind().() rust-analyzer cargo r-description 0.4.1 relations/impl#[SyntaxKind][`PartialEq<Self>`]eq().==rust-analyzer cargo r-description 0.4.1 relations/impl#[SyntaxKind][`PartialEq<Self>`]eq(). rust-analyzer cargo r-description 0.4.1 relations/impl#[SyntaxKind][`PartialEq<Self>`]eq().IDENTrust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#IDENT# => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(token),
1145 _ => Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
1146 })
1147 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().()
1148 .textrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxToken<L>`]text().()
1149 .to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()
1150 }
1151
1152 /// Return the version constraint and the version it is constrained to.
1153 pub fn versionrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relation]version().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<(VersionConstraintrust-analyzer cargo r-description 0.4.1 relations/VersionConstraint#, Versionrust-analyzer cargo r-description 0.4.1 lossless/relations/Version#)> {
1154 let vc = self.0rust-analyzer cargo r-description 0.4.1 lossless/relations/Relation#0..childrenrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]children().().findrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#find().(|n| n.kindrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]kind().() rust-analyzer cargo r-description 0.4.1 relations/impl#[SyntaxKind][`PartialEq<Self>`]eq().==rust-analyzer cargo r-description 0.4.1 relations/impl#[SyntaxKind][`PartialEq<Self>`]eq(). rust-analyzer cargo r-description 0.4.1 relations/impl#[SyntaxKind][`PartialEq<Self>`]eq().VERSIONrust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#VERSION#);
1155 let vc = vc.as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Try]branch().;
1156 let constraint = vc.childrenrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]children().().findrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#find().(|n| n.kindrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]kind().() rust-analyzer cargo r-description 0.4.1 relations/impl#[SyntaxKind][`PartialEq<Self>`]eq().==rust-analyzer cargo r-description 0.4.1 relations/impl#[SyntaxKind][`PartialEq<Self>`]eq(). rust-analyzer cargo r-description 0.4.1 relations/impl#[SyntaxKind][`PartialEq<Self>`]eq().CONSTRAINTrust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#CONSTRAINT#);
1157
1158 let version = vc.children_with_tokensrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]children_with_tokens().().find_maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#find_map().(|it| match it {
1159 SyntaxElementrust-analyzer cargo r-description 0.4.1 lossless/relations/SyntaxElement#::Tokenrust-analyzer cargo rowan 0.16.1 utility_types/NodeOrToken#Token#(token) if token.kindrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxToken<L>`]kind().() rust-analyzer cargo r-description 0.4.1 relations/impl#[SyntaxKind][`PartialEq<Self>`]eq().==rust-analyzer cargo r-description 0.4.1 relations/impl#[SyntaxKind][`PartialEq<Self>`]eq(). rust-analyzer cargo r-description 0.4.1 relations/impl#[SyntaxKind][`PartialEq<Self>`]eq().IDENTrust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#IDENT# => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(token),
1160 _ => Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
1161 });
1162
1163 if let (Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(constraint), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(version)) = (constraint, version) {
1164 let vc: VersionConstraintrust-analyzer cargo r-description 0.4.1 relations/VersionConstraint# = constraint.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().().parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
1165 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((vc, (version.textrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxToken<L>`]text().().to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()).parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()))
1166 } else {
1167 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#
1168 }
1169 }
1170
1171 /// Set the version constraint for this relation
1172 ///
1173 /// # Example
1174 /// ```
1175 /// use r_description::lossless::{Relation};
1176 /// use r_description::VersionConstraint;
1177 /// let mut relation = Relation::simple("vign");
1178 /// relation.set_version(Some((VersionConstraint::GreaterThanEqual, "2.0".parse().unwrap())));
1179 /// assert_eq!(relation.to_string(), "vign (>= 2.0)");
1180 /// ```
1181 pub fn set_versionrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relation]set_version().(&mut self, version_constraint: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<(VersionConstraintrust-analyzer cargo r-description 0.4.1 relations/VersionConstraint#, Versionrust-analyzer cargo r-description 0.4.1 lossless/relations/Version#)>) {
1182 let current_version = self.0rust-analyzer cargo r-description 0.4.1 lossless/relations/Relation#0..childrenrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]children().().findrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#find().(|n| n.kindrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]kind().() rust-analyzer cargo r-description 0.4.1 relations/impl#[SyntaxKind][`PartialEq<Self>`]eq().==rust-analyzer cargo r-description 0.4.1 relations/impl#[SyntaxKind][`PartialEq<Self>`]eq(). rust-analyzer cargo r-description 0.4.1 relations/impl#[SyntaxKind][`PartialEq<Self>`]eq().VERSIONrust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#VERSION#);
1183 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((vc, version)) = version_constraint {
1184 let mut builder = GreenNodeBuilderrust-analyzer cargo rowan 0.16.1 green/builder/GreenNodeBuilder#::newrust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]new().();
1185 builder.start_noderust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]start_node().(VERSIONrust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#VERSION#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
1186 builder.tokenrust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]token().(L_PARENSrust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#L_PARENS#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), "(");
1187 builder.start_noderust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]start_node().(CONSTRAINTrust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#CONSTRAINT#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
1188 push_constraint_tokensrust-analyzer cargo r-description 0.4.1 lossless/relations/push_constraint_tokens().(&mut builder, &vc);
1189 builder.finish_noderust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]finish_node().(); // CONSTRAINT
1190 builder.tokenrust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]token().(WHITESPACErust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#WHITESPACE#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), " ");
1191 builder.tokenrust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]token().(IDENTrust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#IDENT#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), version.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().().as_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]as_str().());
1192 builder.tokenrust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]token().(R_PARENSrust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#R_PARENS#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), ")");
1193 builder.finish_noderust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]finish_node().(); // VERSION
1194
1195 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(current_version) = current_version {
1196 self.0rust-analyzer cargo r-description 0.4.1 lossless/relations/Relation#0..splice_childrenrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]splice_children().(
1197 current_version.indexrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]index().()..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#current_version.indexrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]index().() 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,
1198 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![SyntaxNoderust-analyzer cargo r-description 0.4.1 lossless/relations/SyntaxNode#::new_root_mutrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]new_root_mut().(builder.finishrust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]finish().()).intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()],
1199 );
1200 } else {
1201 let name_node = self.0rust-analyzer cargo r-description 0.4.1 lossless/relations/Relation#0..children_with_tokensrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]children_with_tokens().().findrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#find().(|n| n.kindrust-analyzer cargo rowan 0.16.1 api/impl#[`NodeOrToken<SyntaxNode<L>, SyntaxToken<L>>`]kind().() rust-analyzer cargo r-description 0.4.1 relations/impl#[SyntaxKind][`PartialEq<Self>`]eq().==rust-analyzer cargo r-description 0.4.1 relations/impl#[SyntaxKind][`PartialEq<Self>`]eq(). rust-analyzer cargo r-description 0.4.1 relations/impl#[SyntaxKind][`PartialEq<Self>`]eq().IDENTrust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#IDENT#);
1202 let idx = if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(name_node) = name_node {
1203 name_node.indexrust-analyzer cargo rowan 0.16.1 api/impl#[`NodeOrToken<SyntaxNode<L>, SyntaxToken<L>>`]index().() 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
1204 } else {
1205 0
1206 };
1207 let new_children = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![
1208 GreenTokenrust-analyzer cargo rowan 0.16.1 green/token/GreenToken#::newrust-analyzer cargo rowan 0.16.1 green/token/impl#[GreenToken]new().(WHITESPACErust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#WHITESPACE#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), " ").intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(),
1209 builder.finishrust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]finish().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(),
1210 ];
1211 let new_root = SyntaxNoderust-analyzer cargo r-description 0.4.1 lossless/relations/SyntaxNode#::new_root_mutrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]new_root_mut().(
1212 self.0rust-analyzer cargo r-description 0.4.1 lossless/relations/Relation#0..greenrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]green().().splice_childrenrust-analyzer cargo rowan 0.16.1 green/node/impl#[GreenNodeData]splice_children().(idx..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#idx, new_children),
1213 );
1214 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(parent) = self.0rust-analyzer cargo r-description 0.4.1 lossless/relations/Relation#0..parentrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]parent().() {
1215 parent.splice_childrenrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]splice_children().(
1216 self.0rust-analyzer cargo r-description 0.4.1 lossless/relations/Relation#0..indexrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]index().()..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#self.0rust-analyzer cargo r-description 0.4.1 lossless/relations/Relation#0..indexrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]index().() 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,
1217 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![new_root.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()],
1218 );
1219 self.0rust-analyzer cargo r-description 0.4.1 lossless/relations/Relation#0. = parent
1220 .children_with_tokensrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]children_with_tokens().()
1221 .nthrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#nth().(self.0rust-analyzer cargo r-description 0.4.1 lossless/relations/Relation#0..indexrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]index().())
1222 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().()
1223 .clonerust-analyzer cargo rowan 0.16.1 utility_types/impl#[`NodeOrToken<N, T>`][Clone]clone().()
1224 .into_noderust-analyzer cargo rowan 0.16.1 utility_types/impl#[`NodeOrToken<N, T>`]into_node().()
1225 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().();
1226 } else {
1227 self.0rust-analyzer cargo r-description 0.4.1 lossless/relations/Relation#0. = new_root;
1228 }
1229 }
1230 } else if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(current_version) = current_version {
1231 // Remove any whitespace before the version token
1232 while let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(prev) = current_version.prev_sibling_or_tokenrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]prev_sibling_or_token().() {
1233 if prev.kindrust-analyzer cargo rowan 0.16.1 api/impl#[`NodeOrToken<SyntaxNode<L>, SyntaxToken<L>>`]kind().() rust-analyzer cargo r-description 0.4.1 relations/impl#[SyntaxKind][`PartialEq<Self>`]eq().==rust-analyzer cargo r-description 0.4.1 relations/impl#[SyntaxKind][`PartialEq<Self>`]eq(). rust-analyzer cargo r-description 0.4.1 relations/impl#[SyntaxKind][`PartialEq<Self>`]eq().WHITESPACErust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#WHITESPACE# || prev.kindrust-analyzer cargo rowan 0.16.1 api/impl#[`NodeOrToken<SyntaxNode<L>, SyntaxToken<L>>`]kind().() rust-analyzer cargo r-description 0.4.1 relations/impl#[SyntaxKind][`PartialEq<Self>`]eq().==rust-analyzer cargo r-description 0.4.1 relations/impl#[SyntaxKind][`PartialEq<Self>`]eq(). rust-analyzer cargo r-description 0.4.1 relations/impl#[SyntaxKind][`PartialEq<Self>`]eq().NEWLINErust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#NEWLINE# {
1234 prev.detachrust-analyzer cargo rowan 0.16.1 api/impl#[`NodeOrToken<SyntaxNode<L>, SyntaxToken<L>>`]detach().();
1235 } else {
1236 break;
1237 }
1238 }
1239 current_version.detachrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]detach().();
1240 }
1241 }
1242
1243 /// Remove this relation
1244 ///
1245 /// # Example
1246 /// ```
1247 /// use r_description::lossless::{Relation, Relations};
1248 /// let mut relations: Relations = r"cli (>= 0.19.0), blah (< 1.26.0)".parse().unwrap();
1249 /// let mut relation = relations.get_relation(0).unwrap();
1250 /// assert_eq!(relation.to_string(), "cli (>= 0.19.0)");
1251 /// relation.remove();
1252 /// assert_eq!(relations.to_string(), "blah (< 1.26.0)");
1253 /// ```
1254 pub fn removerust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relation]remove().(&mut self) {
1255 let is_first = !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().self
1256 .0rust-analyzer cargo r-description 0.4.1 lossless/relations/Relation#0.
1257 .siblingsrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]siblings().(Directionrust-analyzer cargo rowan 0.16.1 utility_types/Direction#::Prevrust-analyzer cargo rowan 0.16.1 utility_types/Direction#Prev#)
1258 .skiprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#skip().(1)
1259 .anyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#any().(|n| n.kindrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]kind().() rust-analyzer cargo r-description 0.4.1 relations/impl#[SyntaxKind][`PartialEq<Self>`]eq().==rust-analyzer cargo r-description 0.4.1 relations/impl#[SyntaxKind][`PartialEq<Self>`]eq(). rust-analyzer cargo r-description 0.4.1 relations/impl#[SyntaxKind][`PartialEq<Self>`]eq().RELATIONrust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#RELATION#);
1260 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().is_first {
1261 // Not the first item in the list. Remove whitespace backwards to the previous
1262 // pipe, the pipe and any whitespace until the previous relation
1263 while let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(n) = self.0rust-analyzer cargo r-description 0.4.1 lossless/relations/Relation#0..prev_sibling_or_tokenrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]prev_sibling_or_token().() {
1264 if n.kindrust-analyzer cargo rowan 0.16.1 api/impl#[`NodeOrToken<SyntaxNode<L>, SyntaxToken<L>>`]kind().() rust-analyzer cargo r-description 0.4.1 relations/impl#[SyntaxKind][`PartialEq<Self>`]eq().==rust-analyzer cargo r-description 0.4.1 relations/impl#[SyntaxKind][`PartialEq<Self>`]eq(). rust-analyzer cargo r-description 0.4.1 relations/impl#[SyntaxKind][`PartialEq<Self>`]eq().WHITESPACErust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#WHITESPACE# || n.kindrust-analyzer cargo rowan 0.16.1 api/impl#[`NodeOrToken<SyntaxNode<L>, SyntaxToken<L>>`]kind().() rust-analyzer cargo r-description 0.4.1 relations/impl#[SyntaxKind][`PartialEq<Self>`]eq().==rust-analyzer cargo r-description 0.4.1 relations/impl#[SyntaxKind][`PartialEq<Self>`]eq(). rust-analyzer cargo r-description 0.4.1 relations/impl#[SyntaxKind][`PartialEq<Self>`]eq().NEWLINErust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#NEWLINE# {
1265 n.detachrust-analyzer cargo rowan 0.16.1 api/impl#[`NodeOrToken<SyntaxNode<L>, SyntaxToken<L>>`]detach().();
1266 } else if n.kindrust-analyzer cargo rowan 0.16.1 api/impl#[`NodeOrToken<SyntaxNode<L>, SyntaxToken<L>>`]kind().() rust-analyzer cargo r-description 0.4.1 relations/impl#[SyntaxKind][`PartialEq<Self>`]eq().==rust-analyzer cargo r-description 0.4.1 relations/impl#[SyntaxKind][`PartialEq<Self>`]eq(). rust-analyzer cargo r-description 0.4.1 relations/impl#[SyntaxKind][`PartialEq<Self>`]eq().COMMArust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#COMMA# {
1267 n.detachrust-analyzer cargo rowan 0.16.1 api/impl#[`NodeOrToken<SyntaxNode<L>, SyntaxToken<L>>`]detach().();
1268 break;
1269 } else {
1270 break;
1271 }
1272 }
1273 while let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(n) = self.0rust-analyzer cargo r-description 0.4.1 lossless/relations/Relation#0..prev_sibling_or_tokenrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]prev_sibling_or_token().() {
1274 if n.kindrust-analyzer cargo rowan 0.16.1 api/impl#[`NodeOrToken<SyntaxNode<L>, SyntaxToken<L>>`]kind().() rust-analyzer cargo r-description 0.4.1 relations/impl#[SyntaxKind][`PartialEq<Self>`]eq().==rust-analyzer cargo r-description 0.4.1 relations/impl#[SyntaxKind][`PartialEq<Self>`]eq(). rust-analyzer cargo r-description 0.4.1 relations/impl#[SyntaxKind][`PartialEq<Self>`]eq().WHITESPACErust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#WHITESPACE# || n.kindrust-analyzer cargo rowan 0.16.1 api/impl#[`NodeOrToken<SyntaxNode<L>, SyntaxToken<L>>`]kind().() rust-analyzer cargo r-description 0.4.1 relations/impl#[SyntaxKind][`PartialEq<Self>`]eq().==rust-analyzer cargo r-description 0.4.1 relations/impl#[SyntaxKind][`PartialEq<Self>`]eq(). rust-analyzer cargo r-description 0.4.1 relations/impl#[SyntaxKind][`PartialEq<Self>`]eq().NEWLINErust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#NEWLINE# {
1275 n.detachrust-analyzer cargo rowan 0.16.1 api/impl#[`NodeOrToken<SyntaxNode<L>, SyntaxToken<L>>`]detach().();
1276 } else {
1277 break;
1278 }
1279 }
1280 } else {
1281 // First item in the list. Remove whitespace up to the pipe, the pipe and anything
1282 // before the next relation
1283 while let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(n) = self.0rust-analyzer cargo r-description 0.4.1 lossless/relations/Relation#0..next_sibling_or_tokenrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]next_sibling_or_token().() {
1284 if n.kindrust-analyzer cargo rowan 0.16.1 api/impl#[`NodeOrToken<SyntaxNode<L>, SyntaxToken<L>>`]kind().() rust-analyzer cargo r-description 0.4.1 relations/impl#[SyntaxKind][`PartialEq<Self>`]eq().==rust-analyzer cargo r-description 0.4.1 relations/impl#[SyntaxKind][`PartialEq<Self>`]eq(). rust-analyzer cargo r-description 0.4.1 relations/impl#[SyntaxKind][`PartialEq<Self>`]eq().WHITESPACErust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#WHITESPACE# || n.kindrust-analyzer cargo rowan 0.16.1 api/impl#[`NodeOrToken<SyntaxNode<L>, SyntaxToken<L>>`]kind().() rust-analyzer cargo r-description 0.4.1 relations/impl#[SyntaxKind][`PartialEq<Self>`]eq().==rust-analyzer cargo r-description 0.4.1 relations/impl#[SyntaxKind][`PartialEq<Self>`]eq(). rust-analyzer cargo r-description 0.4.1 relations/impl#[SyntaxKind][`PartialEq<Self>`]eq().NEWLINErust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#NEWLINE# {
1285 n.detachrust-analyzer cargo rowan 0.16.1 api/impl#[`NodeOrToken<SyntaxNode<L>, SyntaxToken<L>>`]detach().();
1286 } else if n.kindrust-analyzer cargo rowan 0.16.1 api/impl#[`NodeOrToken<SyntaxNode<L>, SyntaxToken<L>>`]kind().() rust-analyzer cargo r-description 0.4.1 relations/impl#[SyntaxKind][`PartialEq<Self>`]eq().==rust-analyzer cargo r-description 0.4.1 relations/impl#[SyntaxKind][`PartialEq<Self>`]eq(). rust-analyzer cargo r-description 0.4.1 relations/impl#[SyntaxKind][`PartialEq<Self>`]eq().COMMArust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#COMMA# {
1287 n.detachrust-analyzer cargo rowan 0.16.1 api/impl#[`NodeOrToken<SyntaxNode<L>, SyntaxToken<L>>`]detach().();
1288 break;
1289 } else {
1290 panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("Unexpected node: {n:?}");
1291 }
1292 }
1293
1294 while let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(n) = self.0rust-analyzer cargo r-description 0.4.1 lossless/relations/Relation#0..next_sibling_or_tokenrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]next_sibling_or_token().() {
1295 if n.kindrust-analyzer cargo rowan 0.16.1 api/impl#[`NodeOrToken<SyntaxNode<L>, SyntaxToken<L>>`]kind().() rust-analyzer cargo r-description 0.4.1 relations/impl#[SyntaxKind][`PartialEq<Self>`]eq().==rust-analyzer cargo r-description 0.4.1 relations/impl#[SyntaxKind][`PartialEq<Self>`]eq(). rust-analyzer cargo r-description 0.4.1 relations/impl#[SyntaxKind][`PartialEq<Self>`]eq().WHITESPACErust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#WHITESPACE# || n.kindrust-analyzer cargo rowan 0.16.1 api/impl#[`NodeOrToken<SyntaxNode<L>, SyntaxToken<L>>`]kind().() rust-analyzer cargo r-description 0.4.1 relations/impl#[SyntaxKind][`PartialEq<Self>`]eq().==rust-analyzer cargo r-description 0.4.1 relations/impl#[SyntaxKind][`PartialEq<Self>`]eq(). rust-analyzer cargo r-description 0.4.1 relations/impl#[SyntaxKind][`PartialEq<Self>`]eq().NEWLINErust-analyzer cargo r-description 0.4.1 relations/SyntaxKind#NEWLINE# {
1296 n.detachrust-analyzer cargo rowan 0.16.1 api/impl#[`NodeOrToken<SyntaxNode<L>, SyntaxToken<L>>`]detach().();
1297 } else {
1298 break;
1299 }
1300 }
1301 }
1302 self.0rust-analyzer cargo r-description 0.4.1 lossless/relations/Relation#0..detachrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]detach().();
1303 }
1304
1305 /// Check if this relation is satisfied by the given package version.
1306 pub fn satisfied_byrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relation]satisfied_by().(
1307 &self,
1308 package_version: impl craterust-analyzer cargo r-description 0.4.1 crate/::relationsrust-analyzer cargo r-description 0.4.1 relations/::VersionLookuprust-analyzer cargo r-description 0.4.1 relations/VersionLookup# + Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy#,
1309 ) -> bool {
1310 let name = self.namerust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relation]name().();
1311 let version = self.versionrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relation]version().();
1312 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(version) = version {
1313 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(package_version) = package_version.lookup_versionrust-analyzer cargo r-description 0.4.1 relations/VersionLookup#lookup_version().(&name) {
1314 let required: LossyVersionrust-analyzer cargo r-description 0.4.1 version/Version# = version.1.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().();
1315 let actual = package_version.into_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/impl#[`Cow<'_, B>`]into_owned().();
1316 match version.0 {
1317 VersionConstraintrust-analyzer cargo r-description 0.4.1 relations/VersionConstraint#::GreaterThanEqualrust-analyzer cargo r-description 0.4.1 relations/VersionConstraint#GreaterThanEqual# => actual rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#ge().required,
1318 VersionConstraintrust-analyzer cargo r-description 0.4.1 relations/VersionConstraint#::LessThanEqualrust-analyzer cargo r-description 0.4.1 relations/VersionConstraint#LessThanEqual# => actual rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#le().<=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#le(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#le().required,
1319 VersionConstraintrust-analyzer cargo r-description 0.4.1 relations/VersionConstraint#::Equalrust-analyzer cargo r-description 0.4.1 relations/VersionConstraint#Equal# => actual rust-analyzer cargo r-description 0.4.1 version/impl#[Version][`PartialEq<Self>`]eq().==rust-analyzer cargo r-description 0.4.1 version/impl#[Version][`PartialEq<Self>`]eq(). rust-analyzer cargo r-description 0.4.1 version/impl#[Version][`PartialEq<Self>`]eq().required,
1320 VersionConstraintrust-analyzer cargo r-description 0.4.1 relations/VersionConstraint#::NotEqualrust-analyzer cargo r-description 0.4.1 relations/VersionConstraint#NotEqual# => actual rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne().required,
1321 VersionConstraintrust-analyzer cargo r-description 0.4.1 relations/VersionConstraint#::GreaterThanrust-analyzer cargo r-description 0.4.1 relations/VersionConstraint#GreaterThan# => actual rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#gt().required,
1322 VersionConstraintrust-analyzer cargo r-description 0.4.1 relations/VersionConstraint#::LessThanrust-analyzer cargo r-description 0.4.1 relations/VersionConstraint#LessThan# => actual rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#lt().required,
1323 }
1324 } else {
1325 false
1326 }
1327 } else {
1328 true
1329 }
1330 }
1331 }
1332
1333 impl PartialOrdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd# for Relationrust-analyzer cargo r-description 0.4.1 lossless/relations/Relation# {
1334 fn partial_cmprust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relation][`PartialOrd<Self>`]partial_cmp().(&self, other: &Selfrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relation][`PartialOrd<Self>`]) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::cmprust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/::Orderingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ordering#> {
1335 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(self.cmprust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relation][Ord]cmp().(other))
1336 }
1337 }
1338
1339 impl Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq# for Relationrust-analyzer cargo r-description 0.4.1 lossless/relations/Relation# {}
1340
1341 impl Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord# for Relationrust-analyzer cargo r-description 0.4.1 lossless/relations/Relation# {
1342 fn cmprust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relation][Ord]cmp().(&self, other: &Selfrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relation][Ord]) -> stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::cmprust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/::Orderingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ordering# {
1343 // Compare by name first, then by version
1344 let name_cmp = self.namerust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relation]name().().cmprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][Ord]cmp().(&other.namerust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relation]name().());
1345 if name_cmp rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne().stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::cmprust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/::Orderingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ordering#::Equalrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ordering#Equal# {
1346 return name_cmp;
1347 }
1348
1349 let self_version = self.versionrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relation]version().();
1350 let other_version = other.versionrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relation]version().();
1351
1352 match (self_version, other_version) {
1353 (Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((self_vc, self_version)), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((other_vc, other_version))) => {
1354 let vc_cmp = self_vc.cmprust-analyzer cargo r-description 0.4.1 relations/impl#[VersionConstraint][Ord]cmp().(&other_vc);
1355 if vc_cmp rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne().stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::cmprust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/::Orderingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ordering#::Equalrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ordering#Equal# {
1356 return vc_cmp;
1357 }
1358
1359 self_version.cmprust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Version][Ord]cmp().(&other_version)
1360 }
1361 (Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(_), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#) => stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::cmprust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/::Orderingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ordering#::Greaterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ordering#Greater#,
1362 (Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(_)) => stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::cmprust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/::Orderingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ordering#::Lessrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ordering#Less#,
1363 (Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#) => stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::cmprust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/::Orderingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ordering#::Equalrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ordering#Equal#,
1364 }
1365 }
1366 }
1367
1368 impl stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/::FromStrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/traits/FromStr# for Relationsrust-analyzer cargo r-description 0.4.1 lossless/relations/Relations# {
1369 type Errrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relations][FromStr]Err# = Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#;
1370
1371 fn from_strrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relations][FromStr]from_str().(s: &str) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relations][FromStr], Selfrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relations][FromStr]::Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/traits/FromStr#Err#> {
1372 let parse = parserust-analyzer cargo r-description 0.4.1 lossless/relations/parse().(s);
1373 if parse.errorsrust-analyzer cargo r-description 0.4.1 lossless/relations/Parse#errors..is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().() {
1374 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(parse.root_mutrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Parse]root_mut().())
1375 } else {
1376 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(parse.errorsrust-analyzer cargo r-description 0.4.1 lossless/relations/Parse#errors..joinrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]join().("\n"))
1377 }
1378 }
1379 }
1380
1381 impl stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/::FromStrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/traits/FromStr# for Relationrust-analyzer cargo r-description 0.4.1 lossless/relations/Relation# {
1382 type Errrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relation][FromStr]Err# = Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#;
1383
1384 fn from_strrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relation][FromStr]from_str().(s: &str) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relation][FromStr], Selfrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relation][FromStr]::Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/traits/FromStr#Err#> {
1385 let rels = s.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().::<Relationsrust-analyzer cargo r-description 0.4.1 lossless/relations/Relations#>()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
1386 let mut relations = rels.relationsrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relations]relations().();
1387
1388 let relation = if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(relation) = relations.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/filter_map/impl#[`FilterMap<I, F>`][Iterator]next().() {
1389 relation
1390 } else {
1391 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#("No relation found".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().());
1392 };
1393
1394 if relations.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/filter_map/impl#[`FilterMap<I, F>`][Iterator]next().().is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().() {
1395 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#("Multiple relations found".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().());
1396 }
1397
1398 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(relation)
1399 }
1400 }
1401
1402 #[cfg(test)]
1403 mod testsrust-analyzer cargo r-description 0.4.1 lossless/relations/tests/ {
1404 use superrust-analyzer cargo r-description 0.4.1 lossless/relations/::*;
1405
1406 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1407 fn test_parserust-analyzer cargo r-description 0.4.1 lossless/relations/tests/test_parse().() {
1408 let input = "cli";
1409 let parsed: Relationsrust-analyzer cargo r-description 0.4.1 lossless/relations/Relations# = input.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
1410 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(parsed.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), input);
1411 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(parsed.relationsrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relations]relations().().countrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#count().(), 1);
1412 let relation = parsed.relationsrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relations]relations().().nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/filter_map/impl#[`FilterMap<I, F>`][Iterator]next().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().();
1413 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(relation.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "cli");
1414 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(relation.versionrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relation]version().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
1415
1416 let input = "cli (>= 0.20.21)";
1417 let parsed: Relationsrust-analyzer cargo r-description 0.4.1 lossless/relations/Relations# = input.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
1418 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(parsed.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), input);
1419 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(parsed.relationsrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relations]relations().().countrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#count().(), 1);
1420 let relation = parsed.relationsrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relations]relations().().nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/filter_map/impl#[`FilterMap<I, F>`][Iterator]next().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().();
1421 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(relation.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "cli (>= 0.20.21)");
1422 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
1423 relation.versionrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relation]version().(),
1424 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((
1425 VersionConstraintrust-analyzer cargo r-description 0.4.1 relations/VersionConstraint#::GreaterThanEqualrust-analyzer cargo r-description 0.4.1 relations/VersionConstraint#GreaterThanEqual#,
1426 "0.20.21".parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()
1427 ))
1428 );
1429
1430 let input = "xml2 (> 1.0.0)";
1431 let parsed: Relationsrust-analyzer cargo r-description 0.4.1 lossless/relations/Relations# = input.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
1432 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(parsed.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), input);
1433 let relation = parsed.relationsrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relations]relations().().nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/filter_map/impl#[`FilterMap<I, F>`][Iterator]next().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().();
1434 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
1435 relation.versionrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relation]version().(),
1436 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((VersionConstraintrust-analyzer cargo r-description 0.4.1 relations/VersionConstraint#::GreaterThanrust-analyzer cargo r-description 0.4.1 relations/VersionConstraint#GreaterThan#, "1.0.0".parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()))
1437 );
1438
1439 let input = "xml2 (< 2.0.0)";
1440 let parsed: Relationsrust-analyzer cargo r-description 0.4.1 lossless/relations/Relations# = input.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
1441 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(parsed.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), input);
1442 let relation = parsed.relationsrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relations]relations().().nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/filter_map/impl#[`FilterMap<I, F>`][Iterator]next().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().();
1443 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
1444 relation.versionrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relation]version().(),
1445 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((VersionConstraintrust-analyzer cargo r-description 0.4.1 relations/VersionConstraint#::LessThanrust-analyzer cargo r-description 0.4.1 relations/VersionConstraint#LessThan#, "2.0.0".parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()))
1446 );
1447 }
1448
1449 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1450 fn test_r_equality_operatorsrust-analyzer cargo r-description 0.4.1 lossless/relations/tests/test_r_equality_operators().() {
1451 let input = "xml2 (== 1.0.0)";
1452 let parsed: Relationsrust-analyzer cargo r-description 0.4.1 lossless/relations/Relations# = input.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
1453 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(parsed.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), input);
1454 let relation = parsed.relationsrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relations]relations().().nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/filter_map/impl#[`FilterMap<I, F>`][Iterator]next().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().();
1455 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
1456 relation.versionrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relation]version().(),
1457 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((VersionConstraintrust-analyzer cargo r-description 0.4.1 relations/VersionConstraint#::Equalrust-analyzer cargo r-description 0.4.1 relations/VersionConstraint#Equal#, "1.0.0".parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()))
1458 );
1459
1460 let input = "xml2 (!= 1.0.0)";
1461 let parsed: Relationsrust-analyzer cargo r-description 0.4.1 lossless/relations/Relations# = input.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
1462 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(parsed.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), input);
1463 let relation = parsed.relationsrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relations]relations().().nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/filter_map/impl#[`FilterMap<I, F>`][Iterator]next().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().();
1464 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
1465 relation.versionrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relation]version().(),
1466 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((VersionConstraintrust-analyzer cargo r-description 0.4.1 relations/VersionConstraint#::NotEqualrust-analyzer cargo r-description 0.4.1 relations/VersionConstraint#NotEqual#, "1.0.0".parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()))
1467 );
1468 }
1469
1470 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1471 fn test_constructed_relations_use_r_operatorsrust-analyzer cargo r-description 0.4.1 lossless/relations/tests/test_constructed_relations_use_r_operators().() {
1472 let cases = [
1473 (VersionConstraintrust-analyzer cargo r-description 0.4.1 relations/VersionConstraint#::LessThanrust-analyzer cargo r-description 0.4.1 relations/VersionConstraint#LessThan#, "xml2 (< 1.0)"),
1474 (VersionConstraintrust-analyzer cargo r-description 0.4.1 relations/VersionConstraint#::LessThanEqualrust-analyzer cargo r-description 0.4.1 relations/VersionConstraint#LessThanEqual#, "xml2 (<= 1.0)"),
1475 (VersionConstraintrust-analyzer cargo r-description 0.4.1 relations/VersionConstraint#::Equalrust-analyzer cargo r-description 0.4.1 relations/VersionConstraint#Equal#, "xml2 (== 1.0)"),
1476 (VersionConstraintrust-analyzer cargo r-description 0.4.1 relations/VersionConstraint#::NotEqualrust-analyzer cargo r-description 0.4.1 relations/VersionConstraint#NotEqual#, "xml2 (!= 1.0)"),
1477 (VersionConstraintrust-analyzer cargo r-description 0.4.1 relations/VersionConstraint#::GreaterThanrust-analyzer cargo r-description 0.4.1 relations/VersionConstraint#GreaterThan#, "xml2 (> 1.0)"),
1478 (VersionConstraintrust-analyzer cargo r-description 0.4.1 relations/VersionConstraint#::GreaterThanEqualrust-analyzer cargo r-description 0.4.1 relations/VersionConstraint#GreaterThanEqual#, "xml2 (>= 1.0)"),
1479 ];
1480 for (vc, expected) in cases {
1481 let relation = Relationrust-analyzer cargo r-description 0.4.1 lossless/relations/Relation#::newrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relation]new().("xml2", Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((vc, "1.0".parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().())));
1482 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(relation.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), expected);
1483 }
1484 }
1485
1486 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1487 fn test_multiplerust-analyzer cargo r-description 0.4.1 lossless/relations/tests/test_multiple().() {
1488 let input = "cli (>= 0.20.21), cli (< 0.21)";
1489 let parsed: Relationsrust-analyzer cargo r-description 0.4.1 lossless/relations/Relations# = input.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
1490 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(parsed.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), input);
1491 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(parsed.relationsrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relations]relations().().countrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#count().(), 2);
1492 let relation = parsed.relationsrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relations]relations().().nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/filter_map/impl#[`FilterMap<I, F>`][Iterator]next().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().();
1493 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(relation.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "cli (>= 0.20.21)");
1494 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
1495 relation.versionrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relation]version().(),
1496 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((
1497 VersionConstraintrust-analyzer cargo r-description 0.4.1 relations/VersionConstraint#::GreaterThanEqualrust-analyzer cargo r-description 0.4.1 relations/VersionConstraint#GreaterThanEqual#,
1498 "0.20.21".parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()
1499 ))
1500 );
1501 let relation = parsed.relationsrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relations]relations().().nthrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#nth().(1).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().();
1502 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(relation.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "cli (< 0.21)");
1503 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
1504 relation.versionrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relation]version().(),
1505 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((VersionConstraintrust-analyzer cargo r-description 0.4.1 relations/VersionConstraint#::LessThanrust-analyzer cargo r-description 0.4.1 relations/VersionConstraint#LessThan#, "0.21".parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()))
1506 );
1507 }
1508
1509 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1510 fn test_newrust-analyzer cargo r-description 0.4.1 lossless/relations/tests/test_new().() {
1511 let r = Relationrust-analyzer cargo r-description 0.4.1 lossless/relations/Relation#::newrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relation]new().(
1512 "cli",
1513 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((VersionConstraintrust-analyzer cargo r-description 0.4.1 relations/VersionConstraint#::GreaterThanEqualrust-analyzer cargo r-description 0.4.1 relations/VersionConstraint#GreaterThanEqual#, "2.0".parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().())),
1514 );
1515
1516 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(r.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "cli (>= 2.0)");
1517 }
1518
1519 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1520 fn test_drop_constraintrust-analyzer cargo r-description 0.4.1 lossless/relations/tests/test_drop_constraint().() {
1521 let mut r = Relationrust-analyzer cargo r-description 0.4.1 lossless/relations/Relation#::newrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relation]new().(
1522 "cli",
1523 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((VersionConstraintrust-analyzer cargo r-description 0.4.1 relations/VersionConstraint#::GreaterThanEqualrust-analyzer cargo r-description 0.4.1 relations/VersionConstraint#GreaterThanEqual#, "2.0".parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().())),
1524 );
1525
1526 r.drop_constraintrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relation]drop_constraint().();
1527
1528 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(r.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "cli");
1529 }
1530
1531 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1532 fn test_simplerust-analyzer cargo r-description 0.4.1 lossless/relations/tests/test_simple().() {
1533 let r = Relationrust-analyzer cargo r-description 0.4.1 lossless/relations/Relation#::simplerust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relation]simple().("cli");
1534
1535 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(r.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "cli");
1536 }
1537
1538 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1539 fn test_remove_first_relationrust-analyzer cargo r-description 0.4.1 lossless/relations/tests/test_remove_first_relation().() {
1540 let mut rels: Relationsrust-analyzer cargo r-description 0.4.1 lossless/relations/Relations# = r#"cli (>= 0.20.21), cli (< 0.21)"#.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
1541 let removed = rels.remove_relationrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relations]remove_relation().(0);
1542 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(removed.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "cli (>= 0.20.21)");
1543 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(rels.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "cli (< 0.21)");
1544 }
1545
1546 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1547 fn test_remove_last_relationrust-analyzer cargo r-description 0.4.1 lossless/relations/tests/test_remove_last_relation().() {
1548 let mut rels: Relationsrust-analyzer cargo r-description 0.4.1 lossless/relations/Relations# = r#"cli (>= 0.20.21), cli (< 0.21)"#.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
1549 rels.remove_relationrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relations]remove_relation().(1);
1550 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(rels.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "cli (>= 0.20.21)");
1551 }
1552
1553 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1554 fn test_remove_middlerust-analyzer cargo r-description 0.4.1 lossless/relations/tests/test_remove_middle().() {
1555 let mut rels: Relationsrust-analyzer cargo r-description 0.4.1 lossless/relations/Relations# =
1556 r#"cli (>= 0.20.21), cli (< 0.21), cli (< 0.22)"#.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
1557 rels.remove_relationrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relations]remove_relation().(1);
1558 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(rels.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "cli (>= 0.20.21), cli (< 0.22)");
1559 }
1560
1561 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1562 fn test_remove_addedrust-analyzer cargo r-description 0.4.1 lossless/relations/tests/test_remove_added().() {
1563 let mut rels: Relationsrust-analyzer cargo r-description 0.4.1 lossless/relations/Relations# = r#"cli (>= 0.20.21)"#.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
1564 let relation = Relationrust-analyzer cargo r-description 0.4.1 lossless/relations/Relation#::simplerust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relation]simple().("cli");
1565 rels.pushrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relations]push().(relation);
1566 rels.remove_relationrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relations]remove_relation().(1);
1567 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(rels.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "cli (>= 0.20.21)");
1568 }
1569
1570 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1571 fn test_pushrust-analyzer cargo r-description 0.4.1 lossless/relations/tests/test_push().() {
1572 let mut rels: Relationsrust-analyzer cargo r-description 0.4.1 lossless/relations/Relations# = r#"cli (>= 0.20.21)"#.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
1573 let relation = Relationrust-analyzer cargo r-description 0.4.1 lossless/relations/Relation#::simplerust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relation]simple().("cli");
1574 rels.pushrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relations]push().(relation);
1575 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(rels.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "cli (>= 0.20.21), cli");
1576 }
1577
1578 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1579 fn test_push_from_emptyrust-analyzer cargo r-description 0.4.1 lossless/relations/tests/test_push_from_empty().() {
1580 let mut rels: Relationsrust-analyzer cargo r-description 0.4.1 lossless/relations/Relations# = "".parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
1581 let relation = Relationrust-analyzer cargo r-description 0.4.1 lossless/relations/Relation#::simplerust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relation]simple().("cli");
1582 rels.pushrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relations]push().(relation);
1583 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(rels.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "cli");
1584 }
1585
1586 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1587 fn test_insertrust-analyzer cargo r-description 0.4.1 lossless/relations/tests/test_insert().() {
1588 let mut rels: Relationsrust-analyzer cargo r-description 0.4.1 lossless/relations/Relations# = r#"cli (>= 0.20.21), cli (< 0.21)"#.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
1589 let relation = Relationrust-analyzer cargo r-description 0.4.1 lossless/relations/Relation#::simplerust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relation]simple().("cli");
1590 rels.insertrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relations]insert().(1, relation);
1591 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(rels.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "cli (>= 0.20.21), cli, cli (< 0.21)");
1592 }
1593
1594 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1595 fn test_insert_at_startrust-analyzer cargo r-description 0.4.1 lossless/relations/tests/test_insert_at_start().() {
1596 let mut rels: Relationsrust-analyzer cargo r-description 0.4.1 lossless/relations/Relations# = r#"cli (>= 0.20.21), cli (< 0.21)"#.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
1597 let relation = Relationrust-analyzer cargo r-description 0.4.1 lossless/relations/Relation#::simplerust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relation]simple().("cli");
1598 rels.insertrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relations]insert().(0, relation);
1599 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(rels.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "cli, cli (>= 0.20.21), cli (< 0.21)");
1600 }
1601
1602 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1603 fn test_insert_after_errorrust-analyzer cargo r-description 0.4.1 lossless/relations/tests/test_insert_after_error().() {
1604 let (mut rels, errors) = Relationsrust-analyzer cargo r-description 0.4.1 lossless/relations/Relations#::parse_relaxedrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relations]parse_relaxed().("@foo@, debhelper (>= 1.0)");
1605 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
1606 errors,
1607 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![
1608 "expected identifier or comma but got ERROR",
1609 "expected comma or end of file but got Some(IDENT)",
1610 "expected identifier or comma but got ERROR"
1611 ]
1612 );
1613 let relation = Relationrust-analyzer cargo r-description 0.4.1 lossless/relations/Relation#::simplerust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relation]simple().("bar");
1614 rels.pushrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relations]push().(relation);
1615 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(rels.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "@foo@, debhelper (>= 1.0), bar");
1616 }
1617
1618 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1619 fn test_insert_before_errorrust-analyzer cargo r-description 0.4.1 lossless/relations/tests/test_insert_before_error().() {
1620 let (mut rels, errors) = Relationsrust-analyzer cargo r-description 0.4.1 lossless/relations/Relations#::parse_relaxedrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relations]parse_relaxed().("debhelper (>= 1.0), @foo@, bla");
1621 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
1622 errors,
1623 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![
1624 "expected identifier or comma but got ERROR",
1625 "expected comma or end of file but got Some(IDENT)",
1626 "expected identifier or comma but got ERROR"
1627 ]
1628 );
1629 let relation = Relationrust-analyzer cargo r-description 0.4.1 lossless/relations/Relation#::simplerust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relation]simple().("bar");
1630 rels.insertrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relations]insert().(0, relation);
1631 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(rels.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "bar, debhelper (>= 1.0), @foo@, bla");
1632 }
1633
1634 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1635 fn test_replacerust-analyzer cargo r-description 0.4.1 lossless/relations/tests/test_replace().() {
1636 let mut rels: Relationsrust-analyzer cargo r-description 0.4.1 lossless/relations/Relations# = r#"cli (>= 0.20.21), cli (< 0.21)"#.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
1637 let relation = Relationrust-analyzer cargo r-description 0.4.1 lossless/relations/Relation#::simplerust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relation]simple().("cli");
1638 rels.replacerust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relations]replace().(1, relation);
1639 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(rels.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "cli (>= 0.20.21), cli");
1640 }
1641
1642 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1643 fn test_parse_relationrust-analyzer cargo r-description 0.4.1 lossless/relations/tests/test_parse_relation().() {
1644 let parsed: Relationrust-analyzer cargo r-description 0.4.1 lossless/relations/Relation# = "cli (>= 0.20.21)".parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
1645 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(parsed.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "cli (>= 0.20.21)");
1646 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
1647 parsed.versionrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relation]version().(),
1648 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((
1649 VersionConstraintrust-analyzer cargo r-description 0.4.1 relations/VersionConstraint#::GreaterThanEqualrust-analyzer cargo r-description 0.4.1 relations/VersionConstraint#GreaterThanEqual#,
1650 "0.20.21".parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()
1651 ))
1652 );
1653 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
1654 "foo, bar".parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().::<Relationrust-analyzer cargo r-description 0.4.1 lossless/relations/Relation#>().unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().(),
1655 "Multiple relations found"
1656 );
1657 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!("".parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().::<Relationrust-analyzer cargo r-description 0.4.1 lossless/relations/Relation#>().unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().(), "No relation found");
1658 }
1659
1660 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1661 fn test_parse_relation_preserves_version_separatorsrust-analyzer cargo r-description 0.4.1 lossless/relations/tests/test_parse_relation_preserves_version_separators().() {
1662 let parsed: Relationrust-analyzer cargo r-description 0.4.1 lossless/relations/Relation# = "cli (>= 2.5-1)".parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
1663 let (_, version) = parsed.versionrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relation]version().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().();
1664
1665 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(version.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "2.5-1");
1666 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(parsed.wrap_and_sortrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relation]wrap_and_sort().().to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "cli (>= 2.5-1)");
1667 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(version, "2.5.1".parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().::<Versionrust-analyzer cargo r-description 0.4.1 lossless/relations/Version#>().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().());
1668 }
1669
1670 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1671 fn test_relations_satisfied_byrust-analyzer cargo r-description 0.4.1 lossless/relations/tests/test_relations_satisfied_by().() {
1672 let rels: Relationsrust-analyzer cargo r-description 0.4.1 lossless/relations/Relations# = "cli (>= 0.20.21), cli (< 0.21)".parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
1673 let satisfied = |name: &str| -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<LossyVersionrust-analyzer cargo r-description 0.4.1 version/Version#> {
1674 match name {
1675 "cli" => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("0.20.21".parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()),
1676 _ => Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
1677 }
1678 };
1679 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(rels.satisfied_byrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relations]satisfied_by().(satisfied));
1680
1681 let satisfied = |name: &str| match name {
1682 "cli" => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("0.21".parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()),
1683 _ => Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
1684 };
1685 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().rels.satisfied_byrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relations]satisfied_by().(satisfied));
1686
1687 let satisfied = |name: &str| match name {
1688 "cli" => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("0.20.20".parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()),
1689 _ => Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
1690 };
1691 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().rels.satisfied_byrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relations]satisfied_by().(satisfied));
1692 }
1693
1694 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1695 fn test_wrap_and_sort_relationrust-analyzer cargo r-description 0.4.1 lossless/relations/tests/test_wrap_and_sort_relation().() {
1696 let relation: Relationrust-analyzer cargo r-description 0.4.1 lossless/relations/Relation# = " cli (>= 11.0)".parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
1697
1698 let wrapped = relation.wrap_and_sortrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relation]wrap_and_sort().();
1699
1700 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(wrapped.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "cli (>= 11.0)");
1701 }
1702
1703 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1704 fn test_wrap_and_sort_relationsrust-analyzer cargo r-description 0.4.1 lossless/relations/tests/test_wrap_and_sort_relations().() {
1705 let relations: Relationsrust-analyzer cargo r-description 0.4.1 lossless/relations/Relations# = "cli (>= 0.20.21) , \n\n\n\ncli (< 0.21)".parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
1706
1707 let wrapped = relations.wrap_and_sortrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relations]wrap_and_sort().();
1708
1709 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(wrapped.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "cli (< 0.21), cli (>= 0.20.21)");
1710 }
1711
1712 #[cfg(feature = "serde")]
1713 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1714 fn test_serialize_relationsrust-analyzer cargo r-description 0.4.1 lossless/relations/tests/test_serialize_relations().() {
1715 let relations: Relationsrust-analyzer cargo r-description 0.4.1 lossless/relations/Relations# = "cli (>= 0.20.21), cli (< 0.21)".parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
1716 let serialized = serde_jsonrust-analyzer cargo serde_json 1.0.151 crate/::to_stringrust-analyzer cargo serde_json 1.0.151 ser/to_string().(&relations).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
1717 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(serialized, r#""cli (>= 0.20.21), cli (< 0.21)""#);
1718 }
1719
1720 #[cfg(feature = "serde")]
1721 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1722 fn test_deserialize_relationsrust-analyzer cargo r-description 0.4.1 lossless/relations/tests/test_deserialize_relations().() {
1723 let relations: Relationsrust-analyzer cargo r-description 0.4.1 lossless/relations/Relations# = "cli (>= 0.20.21), cli (< 0.21)".parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
1724 let serialized = serde_jsonrust-analyzer cargo serde_json 1.0.151 crate/::to_stringrust-analyzer cargo serde_json 1.0.151 ser/to_string().(&relations).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
1725 let deserialized: Relationsrust-analyzer cargo r-description 0.4.1 lossless/relations/Relations# = serde_jsonrust-analyzer cargo serde_json 1.0.151 crate/::from_strrust-analyzer cargo serde_json 1.0.151 de/from_str().(&serialized).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
1726 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(deserialized.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), relations.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().());
1727 }
1728
1729 #[cfg(feature = "serde")]
1730 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1731 fn test_serialize_relationrust-analyzer cargo r-description 0.4.1 lossless/relations/tests/test_serialize_relation().() {
1732 let relation: Relationrust-analyzer cargo r-description 0.4.1 lossless/relations/Relation# = "cli (>= 0.20.21)".parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
1733 let serialized = serde_jsonrust-analyzer cargo serde_json 1.0.151 crate/::to_stringrust-analyzer cargo serde_json 1.0.151 ser/to_string().(&relation).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
1734 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(serialized, r#""cli (>= 0.20.21)""#);
1735 }
1736
1737 #[cfg(feature = "serde")]
1738 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1739 fn test_deserialize_relationrust-analyzer cargo r-description 0.4.1 lossless/relations/tests/test_deserialize_relation().() {
1740 let relation: Relationrust-analyzer cargo r-description 0.4.1 lossless/relations/Relation# = "cli (>= 0.20.21)".parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
1741 let serialized = serde_jsonrust-analyzer cargo serde_json 1.0.151 crate/::to_stringrust-analyzer cargo serde_json 1.0.151 ser/to_string().(&relation).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
1742 let deserialized: Relationrust-analyzer cargo r-description 0.4.1 lossless/relations/Relation# = serde_jsonrust-analyzer cargo serde_json 1.0.151 crate/::from_strrust-analyzer cargo serde_json 1.0.151 de/from_str().(&serialized).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
1743 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(deserialized.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), relation.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().());
1744 }
1745
1746 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1747 fn test_relation_set_versionrust-analyzer cargo r-description 0.4.1 lossless/relations/tests/test_relation_set_version().() {
1748 let mut rel: Relationrust-analyzer cargo r-description 0.4.1 lossless/relations/Relation# = "vign".parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
1749 rel.set_versionrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relation]set_version().(Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
1750 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!("vign", rel.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().());
1751 rel.set_versionrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relation]set_version().(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((
1752 VersionConstraintrust-analyzer cargo r-description 0.4.1 relations/VersionConstraint#::GreaterThanEqualrust-analyzer cargo r-description 0.4.1 relations/VersionConstraint#GreaterThanEqual#,
1753 "2.0".parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(),
1754 )));
1755 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!("vign (>= 2.0)", rel.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().());
1756 rel.set_versionrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relation]set_version().(Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
1757 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!("vign", rel.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().());
1758 rel.set_versionrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relation]set_version().(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((
1759 VersionConstraintrust-analyzer cargo r-description 0.4.1 relations/VersionConstraint#::GreaterThanEqualrust-analyzer cargo r-description 0.4.1 relations/VersionConstraint#GreaterThanEqual#,
1760 "2.0".parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(),
1761 )));
1762 rel.set_versionrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relation]set_version().(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((
1763 VersionConstraintrust-analyzer cargo r-description 0.4.1 relations/VersionConstraint#::GreaterThanEqualrust-analyzer cargo r-description 0.4.1 relations/VersionConstraint#GreaterThanEqual#,
1764 "1.1".parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(),
1765 )));
1766 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!("vign (>= 1.1)", rel.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().());
1767 }
1768
1769 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1770 fn test_wrap_and_sort_removes_empty_entriesrust-analyzer cargo r-description 0.4.1 lossless/relations/tests/test_wrap_and_sort_removes_empty_entries().() {
1771 let relations: Relationsrust-analyzer cargo r-description 0.4.1 lossless/relations/Relations# = "foo, , bar, ".parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
1772 let wrapped = relations.wrap_and_sortrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relations]wrap_and_sort().();
1773 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(wrapped.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "bar, foo");
1774 }
1775 }
1776 }
1777
1778 #[cfg(test)]
1779 mod testsrust-analyzer cargo r-description 0.4.1 lossless/tests/ {
1780 use superrust-analyzer cargo r-description 0.4.1 lossless/::*;
1781
1782 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1783 fn test_parserust-analyzer cargo r-description 0.4.1 lossless/tests/test_parse().() {
1784 let s = r###"Package: mypackage
1785 Title: What the Package Does (One Line, Title Case)
1786 Version: 0.0.0.9000
1787 Authors@R:
1788 person("First", "Last", , "[email protected]", role = c("aut", "cre"),
1789 comment = c(ORCID = "YOUR-ORCID-ID"))
1790 Description: What the package does (one paragraph).
1791 License: `use_mit_license()`, `use_gpl3_license()` or friends to pick a
1792 license
1793 Encoding: UTF-8
1794 Roxygen: list(markdown = TRUE)
1795 RoxygenNote: 7.3.2
1796 "###;
1797 let desc: RDescriptionrust-analyzer cargo r-description 0.4.1 lossless/RDescription# = s.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
1798
1799 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(desc.packagerust-analyzer cargo r-description 0.4.1 lossless/impl#[RDescription]package().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("mypackage".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()));
1800 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
1801 desc.titlerust-analyzer cargo r-description 0.4.1 lossless/impl#[RDescription]title().(),
1802 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("What the Package Does (One Line, Title Case)".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())
1803 );
1804 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(desc.versionrust-analyzer cargo r-description 0.4.1 lossless/impl#[RDescription]version().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("0.0.0.9000".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()));
1805 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
1806 desc.authorsrust-analyzer cargo r-description 0.4.1 lossless/impl#[RDescription]authors().(),
1807 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(RCoderust-analyzer cargo r-description 0.4.1 RCode#(
1808 r#"person("First", "Last", , "[email protected]", role = c("aut", "cre"),
1809 comment = c(ORCID = "YOUR-ORCID-ID"))"#
1810 .to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()
1811 ))
1812 );
1813 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
1814 desc.descriptionrust-analyzer cargo r-description 0.4.1 lossless/impl#[RDescription]description().(),
1815 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("What the package does (one paragraph).".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())
1816 );
1817 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
1818 desc.licenserust-analyzer cargo r-description 0.4.1 lossless/impl#[RDescription]license().(),
1819 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(
1820 "`use_mit_license()`, `use_gpl3_license()` or friends to pick a\nlicense"
1821 .to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()
1822 )
1823 );
1824 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(desc.encodingrust-analyzer cargo r-description 0.4.1 lossless/impl#[RDescription]encoding().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("UTF-8".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()));
1825 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(desc.roxygenrust-analyzer cargo r-description 0.4.1 lossless/impl#[RDescription]roxygen().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("list(markdown = TRUE)".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()));
1826 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(desc.roxygen_noterust-analyzer cargo r-description 0.4.1 lossless/impl#[RDescription]roxygen_note().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("7.3.2".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()));
1827
1828 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(desc.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), s);
1829 }
1830
1831 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1832 fn test_setters_replace_existing_fieldsrust-analyzer cargo r-description 0.4.1 lossless/tests/test_setters_replace_existing_fields().() {
1833 let s = r###"Package: mypackage
1834 Title: What the Package Does (One Line, Title Case)
1835 Version: 0.0.0.9000
1836 Description: What the package does (one paragraph).
1837 Encoding: UTF-8
1838 "###;
1839 let mut desc: RDescriptionrust-analyzer cargo r-description 0.4.1 lossless/RDescription# = s.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
1840
1841 desc.set_versionrust-analyzer cargo r-description 0.4.1 lossless/impl#[RDescription]set_version().("0.0.1");
1842
1843 // the field is updated in place rather than appended a second time
1844 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(desc.versionrust-analyzer cargo r-description 0.4.1 lossless/impl#[RDescription]version().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("0.0.1".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()));
1845 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(desc.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().().matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]matches().("Version:").countrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#count().(), 1);
1846
1847 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
1848 desc.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(),
1849 r###"Package: mypackage
1850 Title: What the Package Does (One Line, Title Case)
1851 Version: 0.0.1
1852 Description: What the package does (one paragraph).
1853 Encoding: UTF-8
1854 "###
1855 );
1856 }
1857
1858 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1859 fn test_setters_add_missing_fieldsrust-analyzer cargo r-description 0.4.1 lossless/tests/test_setters_add_missing_fields().() {
1860 let s = "Package: mypackage\n";
1861 let mut desc: RDescriptionrust-analyzer cargo r-description 0.4.1 lossless/RDescription# = s.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
1862
1863 desc.set_versionrust-analyzer cargo r-description 0.4.1 lossless/impl#[RDescription]set_version().("0.0.1");
1864
1865 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(desc.versionrust-analyzer cargo r-description 0.4.1 lossless/impl#[RDescription]version().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("0.0.1".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()));
1866 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(desc.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "Package: mypackage\nVersion: 0.0.1\n");
1867 }
1868
1869 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1870 fn test_parse_dplyrrust-analyzer cargo r-description 0.4.1 lossless/tests/test_parse_dplyr().() {
1871 let s = include_strrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/include_str!!("../testdata/dplyr.desc");
1872
1873 let desc: RDescriptionrust-analyzer cargo r-description 0.4.1 lossless/RDescription# = s.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
1874 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!("dplyr", desc.packagerust-analyzer cargo r-description 0.4.1 lossless/impl#[RDescription]package().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().());
1875 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
1876 "https://dplyr.tidyverse.org, https://github.com/tidyverse/dplyr",
1877 desc.urlrust-analyzer cargo r-description 0.4.1 lossless/impl#[RDescription]url().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().as_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]as_str().()
1878 );
1879 }
1880
1881 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1882 fn test_dependency_style_fields_return_relationsrust-analyzer cargo r-description 0.4.1 lossless/tests/test_dependency_style_fields_return_relations().() {
1883 let s = r###"Package: mypackage
1884 Title: What the Package Does
1885 Version: 1.0.0
1886 Description: What the package does.
1887 License: MIT
1888 Imports: cli (>= 2.5-1), glue
1889 Suggests: testthat (>= 3.0.0)
1890 Depends: R (>= 4.1.0)
1891 LinkingTo: cpp11 (>= 0.4-1)
1892 Enhances: shiny
1893 "###;
1894 let desc: RDescriptionrust-analyzer cargo r-description 0.4.1 lossless/RDescription# = s.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
1895
1896 let imports = desc.importsrust-analyzer cargo r-description 0.4.1 lossless/impl#[RDescription]imports().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().();
1897 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(imports.lenrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relations]len().(), 2);
1898 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
1899 imports
1900 .iterrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relations]iter().()
1901 .nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/filter_map/impl#[`FilterMap<I, F>`][Iterator]next().()
1902 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().()
1903 .versionrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relation]version().()
1904 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().()
1905 .1
1906 .to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(),
1907 "2.5-1"
1908 );
1909 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(desc.suggestsrust-analyzer cargo r-description 0.4.1 lossless/impl#[RDescription]suggests().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().lenrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relations]len().(), 1);
1910 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(desc.dependsrust-analyzer cargo r-description 0.4.1 lossless/impl#[RDescription]depends().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().lenrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relations]len().(), 1);
1911 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
1912 desc.linking_torust-analyzer cargo r-description 0.4.1 lossless/impl#[RDescription]linking_to().()
1913 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().()
1914 .iterrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relations]iter().()
1915 .nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/filter_map/impl#[`FilterMap<I, F>`][Iterator]next().()
1916 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().()
1917 .versionrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relation]version().()
1918 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().()
1919 .1
1920 .to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(),
1921 "0.4-1"
1922 );
1923 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
1924 desc.enhancesrust-analyzer cargo r-description 0.4.1 lossless/impl#[RDescription]enhances().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().iterrust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relations]iter().().nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/filter_map/impl#[`FilterMap<I, F>`][Iterator]next().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().namerust-analyzer cargo r-description 0.4.1 lossless/relations/impl#[Relation]name().(),
1925 "shiny"
1926 );
1927 }
1928
1929 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1930 fn test_r_description_additional_repositoriesrust-analyzer cargo r-description 0.4.1 lossless/tests/test_r_description_additional_repositories().() {
1931 let desc: RDescriptionrust-analyzer cargo r-description 0.4.1 lossless/RDescription# = r###"Package: mypackage
1932 Title: What the Package Does
1933 Version: 1.0.0
1934 Description: What the package does.
1935 License: MIT
1936 Additional_repositories: https://example.com/src/contrib,
1937 https://example.org/src/contrib
1938 "###
1939 .parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().()
1940 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
1941
1942 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
1943 desc.additional_repositoriesrust-analyzer cargo r-description 0.4.1 lossless/impl#[RDescription]additional_repositories().(),
1944 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![
1945 "https://example.com/src/contrib".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(),
1946 "https://example.org/src/contrib".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(),
1947 ])
1948 );
1949 }
1950
1951 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1952 fn test_set_additional_repositoriesrust-analyzer cargo r-description 0.4.1 lossless/tests/test_set_additional_repositories().() {
1953 let mut desc: RDescriptionrust-analyzer cargo r-description 0.4.1 lossless/RDescription# = r###"Package: mypackage
1954 Title: What the Package Does
1955 Version: 1.0.0
1956 Description: What the package does.
1957 License: MIT
1958 "###
1959 .parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().()
1960 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
1961
1962 desc.set_additional_repositoriesrust-analyzer cargo r-description 0.4.1 lossless/impl#[RDescription]set_additional_repositories().(&[
1963 "https://example.com/src/contrib",
1964 "https://example.org/src/contrib",
1965 ]);
1966
1967 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
1968 desc.additional_repositoriesrust-analyzer cargo r-description 0.4.1 lossless/impl#[RDescription]additional_repositories().(),
1969 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![
1970 "https://example.com/src/contrib".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(),
1971 "https://example.org/src/contrib".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(),
1972 ])
1973 );
1974 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
1975 desc.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(),
1976 "Package: mypackage\nTitle: What the Package Does\nVersion: 1.0.0\nDescription: What the package does.\nLicense: MIT\nAdditional_repositories: https://example.com/src/contrib, https://example.org/src/contrib\n"
1977 );
1978 }
1979 }