Debian Codegraph @

src/lossless.rs

raw symbols SCIP
1 //! Parser for deb822 style files.
2 //!
3 //! This parser can be used to parse files in the deb822 format, while preserving
4 //! all whitespace and comments. It is based on the [rowan] library, which is a
5 //! lossless parser library for Rust.
6 //!
7 //! Once parsed, the file can be traversed or modified, and then written back to
8 //! a file.
9 //!
10 //! # Example
11 //!
12 //! ```rust
13 //! use deb822_lossless::Deb822;
14 //! use std::str::FromStr;
15 //!
16 //! let input = r###"Package: deb822-lossless
17 //! ## Comments are preserved
18 //! Maintainer: Jelmer Vernooij <[email protected]>
19 //! Homepage: https://github.com/jelmer/deb822-lossless
20 //! Section: rust
21 //!
22 //! Package: deb822-lossless
23 //! Architecture: any
24 //! Description: Lossless parser for deb822 style files.
25 //! This parser can be used to parse files in the deb822 format, while preserving
26 //! all whitespace and comments. It is based on the [rowan] library, which is a
27 //! lossless parser library for Rust.
28 //! "###;
29 //!
30 //! let deb822 = Deb822::from_str(input).unwrap();
31 //! assert_eq!(deb822.paragraphs().count(), 2);
32 //! let homepage = deb822.paragraphs().nth(0).unwrap().get("Homepage");
33 //! assert_eq!(homepage.as_deref(), Some("https://github.com/jelmer/deb822-lossless"));
34 //! ```
35
36 use craterust-analyzer cargo deb822-lossless 0.5.18 crate/::{
37 lexrust-analyzer cargo deb822-lossless 0.5.18 lex/::lexrust-analyzer cargo deb822-lossless 0.5.18 lex/lex().,
38 lexrust-analyzer cargo deb822-lossless 0.5.18 lex/::SyntaxKindrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#::{selfrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#, *},
39 Indentationrust-analyzer cargo deb822-lossless 0.5.18 Indentation#,
40 };
41 use rowanrust-analyzer cargo rowan 0.16.1 crate/::astrust-analyzer cargo rowan 0.16.1 ast/::AstNoderust-analyzer cargo rowan 0.16.1 ast/AstNode#;
42 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/::Pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#;
43 use 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#;
44
45 /// A positioned parse error containing location information.
46 #[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:)]
47 pub struct PositionedParseErrorrust-analyzer cargo deb822-lossless 0.5.18 lossless/PositionedParseError# {
48 /// The error message
49 pub messagerust-analyzer cargo deb822-lossless 0.5.18 lossless/PositionedParseError#message.: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#,
50 /// The text range where the error occurred
51 pub rangerust-analyzer cargo deb822-lossless 0.5.18 lossless/PositionedParseError#range.: rowanrust-analyzer cargo rowan 0.16.1 crate/::TextRangerust-analyzer cargo text-size 1.1.1 range/TextRange#,
52 /// Optional error code for categorization
53 pub coderust-analyzer cargo deb822-lossless 0.5.18 lossless/PositionedParseError#code.: 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#>,
54 }
55
56 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 PositionedParseErrorrust-analyzer cargo deb822-lossless 0.5.18 lossless/PositionedParseError# {
57 fn fmtrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[PositionedParseError][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# {
58 writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "{}", self.messagerust-analyzer cargo deb822-lossless 0.5.18 lossless/PositionedParseError#message.)
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 PositionedParseErrorrust-analyzer cargo deb822-lossless 0.5.18 lossless/PositionedParseError# {}
63
64 /// List of encountered syntax errors.
65 #[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:)]
66 pub struct ParseErrorrust-analyzer cargo deb822-lossless 0.5.18 lossless/ParseError#(pub 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#>);
67
68 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 deb822-lossless 0.5.18 lossless/ParseError# {
69 fn fmtrust-analyzer cargo deb822-lossless 0.5.18 lossless/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# {
70 for err in &self.0rust-analyzer cargo deb822-lossless 0.5.18 lossless/ParseError#0. {
71 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().;
72 }
73 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
74 }
75 }
76
77 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 deb822-lossless 0.5.18 lossless/ParseError# {}
78
79 /// Error parsing deb822 control files
80 #[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:)]
81 pub enum Errorrust-analyzer cargo deb822-lossless 0.5.18 lossless/Error# {
82 /// A syntax error was encountered while parsing the file.
83 ParseErrorrust-analyzer cargo deb822-lossless 0.5.18 lossless/Error#ParseError#(ParseErrorrust-analyzer cargo deb822-lossless 0.5.18 lossless/ParseError#),
84
85 /// An I/O error was encountered while reading the file.
86 IoErrorrust-analyzer cargo deb822-lossless 0.5.18 lossless/Error#IoError#(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#),
87
88 /// An invalid value was provided (e.g., empty continuation lines).
89 InvalidValuerust-analyzer cargo deb822-lossless 0.5.18 lossless/Error#InvalidValue#(Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#),
90 }
91
92 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 deb822-lossless 0.5.18 lossless/Error# {
93 fn fmtrust-analyzer cargo deb822-lossless 0.5.18 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# {
94 match &self {
95 Errorrust-analyzer cargo deb822-lossless 0.5.18 lossless/Error#::ParseErrorrust-analyzer cargo deb822-lossless 0.5.18 lossless/Error#ParseError#(err) => writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "{}", err),
96 Errorrust-analyzer cargo deb822-lossless 0.5.18 lossless/Error#::IoErrorrust-analyzer cargo deb822-lossless 0.5.18 lossless/Error#IoError#(err) => writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "{}", err),
97 Errorrust-analyzer cargo deb822-lossless 0.5.18 lossless/Error#::InvalidValuerust-analyzer cargo deb822-lossless 0.5.18 lossless/Error#InvalidValue#(msg) => writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "Invalid value: {}", msg),
98 }
99 }
100 }
101
102 impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<ParseErrorrust-analyzer cargo deb822-lossless 0.5.18 lossless/ParseError#> for Errorrust-analyzer cargo deb822-lossless 0.5.18 lossless/Error# {
103 fn fromrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Error][`From<ParseError>`]from().(err: ParseErrorrust-analyzer cargo deb822-lossless 0.5.18 lossless/ParseError#) -> Selfrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Error][`From<ParseError>`] {
104 Selfrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Error][`From<ParseError>`]::ParseErrorrust-analyzer cargo deb822-lossless 0.5.18 lossless/Error#ParseError#(err)
105 }
106 }
107
108 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 deb822-lossless 0.5.18 lossless/Error# {
109 fn fromrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Error][`From<std::io::Error>`]from().(err: 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 deb822-lossless 0.5.18 lossless/impl#[Error][`From<std::io::Error>`] {
110 Selfrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Error][`From<std::io::Error>`]::IoErrorrust-analyzer cargo deb822-lossless 0.5.18 lossless/Error#IoError#(err)
111 }
112 }
113
114 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 deb822-lossless 0.5.18 lossless/Error# {}
115
116 /// Second, implementing the `Language` trait teaches rowan to convert between
117 /// these two SyntaxKind types, allowing for a nicer SyntaxNode API where
118 /// "kinds" are values from our `enum SyntaxKind`, instead of plain u16 values.
119 #[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:)]
120 pub enum Langrust-analyzer cargo deb822-lossless 0.5.18 lossless/Lang# {}
121 impl rowanrust-analyzer cargo rowan 0.16.1 crate/::Languagerust-analyzer cargo rowan 0.16.1 api/Language# for Langrust-analyzer cargo deb822-lossless 0.5.18 lossless/Lang# {
122 type Kindrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Lang][Language]Kind# = SyntaxKindrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#;
123 fn kind_from_rawrust-analyzer cargo deb822-lossless 0.5.18 lossless/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 deb822-lossless 0.5.18 lossless/impl#[Lang][Language]::Kindrust-analyzer cargo rowan 0.16.1 api/Language#Kind# {
124 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 deb822-lossless 0.5.18 lex/SyntaxKind#>(raw.0rust-analyzer cargo rowan 0.16.1 green/SyntaxKind#0.) }
125 }
126 fn kind_to_rawrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Lang][Language]kind_to_raw().(kind: Selfrust-analyzer cargo deb822-lossless 0.5.18 lossless/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# {
127 kind.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()
128 }
129 }
130
131 /// GreenNode is an immutable tree, which is cheap to change,
132 /// but doesn't contain offsets and parent pointers.
133 use rowanrust-analyzer cargo rowan 0.16.1 crate/::GreenNoderust-analyzer cargo rowan 0.16.1 green/node/GreenNode#;
134
135 /// You can construct GreenNodes by hand, but a builder
136 /// is helpful for top-down parsers: it maintains a stack
137 /// of currently in-progress nodes
138 use rowanrust-analyzer cargo rowan 0.16.1 crate/::GreenNodeBuilderrust-analyzer cargo rowan 0.16.1 green/builder/GreenNodeBuilder#;
139
140 /// The parse results are stored as a "green tree".
141 /// We'll discuss working with the results later
142 pub(craterust-analyzer cargo deb822-lossless 0.5.18 crate/) struct Parserust-analyzer cargo deb822-lossless 0.5.18 lossless/Parse# {
143 pub(craterust-analyzer cargo deb822-lossless 0.5.18 crate/) green_noderust-analyzer cargo deb822-lossless 0.5.18 lossless/Parse#green_node.: GreenNoderust-analyzer cargo rowan 0.16.1 green/node/GreenNode#,
144 #[allow(unused)]
145 pub(craterust-analyzer cargo deb822-lossless 0.5.18 crate/) errorsrust-analyzer cargo deb822-lossless 0.5.18 lossless/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#>,
146 pub(craterust-analyzer cargo deb822-lossless 0.5.18 crate/) positioned_errorsrust-analyzer cargo deb822-lossless 0.5.18 lossless/Parse#positioned_errors.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<PositionedParseErrorrust-analyzer cargo deb822-lossless 0.5.18 lossless/PositionedParseError#>,
147 }
148
149 pub(craterust-analyzer cargo deb822-lossless 0.5.18 crate/) fn parserust-analyzer cargo deb822-lossless 0.5.18 lossless/parse().(text: &str) -> Parserust-analyzer cargo deb822-lossless 0.5.18 lossless/Parse# {
150 struct Parserrust-analyzer cargo deb822-lossless 0.5.18 lossless/Parser#<'a> {
151 /// input tokens, including whitespace,
152 /// in *reverse* order.
153 tokensrust-analyzer cargo deb822-lossless 0.5.18 lossless/Parser#tokens.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<(SyntaxKindrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#, &'a str)>,
154 /// the in-progress tree.
155 builderrust-analyzer cargo deb822-lossless 0.5.18 lossless/Parser#builder.: GreenNodeBuilderrust-analyzer cargo rowan 0.16.1 green/builder/GreenNodeBuilder#<'static>,
156 /// the list of syntax errors we've accumulated
157 /// so far.
158 errorsrust-analyzer cargo deb822-lossless 0.5.18 lossless/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#>,
159 /// positioned errors with location information
160 positioned_errorsrust-analyzer cargo deb822-lossless 0.5.18 lossless/Parser#positioned_errors.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<PositionedParseErrorrust-analyzer cargo deb822-lossless 0.5.18 lossless/PositionedParseError#>,
161 /// All tokens with their positions in forward order for position tracking
162 token_positionsrust-analyzer cargo deb822-lossless 0.5.18 lossless/Parser#token_positions.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<(SyntaxKindrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#, rowanrust-analyzer cargo rowan 0.16.1 crate/::TextSizerust-analyzer cargo text-size 1.1.1 size/TextSize#, rowanrust-analyzer cargo rowan 0.16.1 crate/::TextSizerust-analyzer cargo text-size 1.1.1 size/TextSize#)>,
163 /// current token index (counting from the end since tokens are in reverse)
164 current_token_indexrust-analyzer cargo deb822-lossless 0.5.18 lossless/Parser#current_token_index.: usize,
165 }
166
167 impl<'a> Parserrust-analyzer cargo deb822-lossless 0.5.18 lossless/Parser#<'a> {
168 /// Skip to next paragraph boundary for error recovery
169 fn skip_to_paragraph_boundaryrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]skip_to_paragraph_boundary().(&mut self) {
170 while self.currentrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]current().().is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().() {
171 match self.currentrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]current().() {
172 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(NEWLINErust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#NEWLINE#) => {
173 self.bumprust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]bump().();
174 // Check if next line starts a new paragraph (key at start of line)
175 if self.at_paragraph_startrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]at_paragraph_start().() {
176 break;
177 }
178 }
179 _ => {
180 self.bumprust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]bump().();
181 }
182 }
183 }
184 }
185
186 /// Check if we're at the start of a new paragraph
187 fn at_paragraph_startrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]at_paragraph_start().(&self) -> bool {
188 match self.currentrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]current().() {
189 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(KEYrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#KEY#) => true,
190 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(COMMENTrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#COMMENT#) => true,
191 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => true, // EOF is a valid paragraph boundary
192 _ => false,
193 }
194 }
195
196 /// Attempt to recover from entry parsing errors
197 fn recover_entryrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]recover_entry().(&mut self) {
198 // Skip to end of current line
199 while self.currentrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]current().().is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().() && self.currentrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]current().() 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().Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(NEWLINErust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#NEWLINE#) {
200 self.bumprust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]bump().();
201 }
202 // Consume the newline if present
203 if self.currentrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]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 deb822-lossless 0.5.18 lex/SyntaxKind#NEWLINE#) {
204 self.bumprust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]bump().();
205 }
206 }
207 fn parse_entryrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]parse_entry().(&mut self) {
208 // Handle leading comments
209 while self.currentrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]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#(COMMENTrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#COMMENT#) {
210 self.bumprust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]bump().();
211
212 match self.currentrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]current().() {
213 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(NEWLINErust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#NEWLINE#) => {
214 self.bumprust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]bump().();
215 }
216 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => {
217 return;
218 }
219 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(g) => {
220 self.builderrust-analyzer cargo deb822-lossless 0.5.18 lossless/Parser#builder..start_noderust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]start_node().(ERRORrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#ERROR#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
221 self.add_positioned_errorrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]add_positioned_error().(
222 formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("expected newline after comment, got {g:?}"),
223 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("unexpected_token_after_comment".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()),
224 );
225 self.bumprust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]bump().();
226 self.builderrust-analyzer cargo deb822-lossless 0.5.18 lossless/Parser#builder..finish_noderust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]finish_node().();
227 self.recover_entryrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]recover_entry().();
228 return;
229 }
230 }
231 }
232
233 self.builderrust-analyzer cargo deb822-lossless 0.5.18 lossless/Parser#builder..start_noderust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]start_node().(ENTRYrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#ENTRY#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
234 let mut entry_has_errors = false;
235
236 // Parse the key
237 if self.currentrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]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#(KEYrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#KEY#) {
238 self.bumprust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]bump().();
239 self.skip_wsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]skip_ws().();
240 } else {
241 entry_has_errors = true;
242 self.builderrust-analyzer cargo deb822-lossless 0.5.18 lossless/Parser#builder..start_noderust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]start_node().(ERRORrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#ERROR#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
243
244 // Enhanced error recovery for malformed keys
245 match self.currentrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]current().() {
246 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(VALUErust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#VALUE#) | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(WHITESPACErust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#WHITESPACE#) => {
247 self.add_positioned_errorrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]add_positioned_error().(
248 "field name cannot start with whitespace or special characters"
249 .to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(),
250 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("invalid_field_name".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()),
251 );
252 // Try to consume what might be an intended key
253 while self.currentrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]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#(VALUErust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#VALUE#) || self.currentrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]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 deb822-lossless 0.5.18 lex/SyntaxKind#WHITESPACE#) {
254 self.bumprust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]bump().();
255 }
256 }
257 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(COLONrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#COLON#) => {
258 self.add_positioned_errorrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]add_positioned_error().(
259 "field name missing before colon".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(),
260 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("missing_field_name".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()),
261 );
262 }
263 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(NEWLINErust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#NEWLINE#) => {
264 self.add_positioned_errorrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]add_positioned_error().(
265 "empty line where field expected".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(),
266 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("empty_field_line".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()),
267 );
268 self.builderrust-analyzer cargo deb822-lossless 0.5.18 lossless/Parser#builder..finish_noderust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]finish_node().();
269 self.builderrust-analyzer cargo deb822-lossless 0.5.18 lossless/Parser#builder..finish_noderust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]finish_node().();
270 return;
271 }
272 _ => {
273 self.add_positioned_errorrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]add_positioned_error().(
274 formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("expected field name, got {:?}", self.currentrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]current().()),
275 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("missing_key".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()),
276 );
277 if self.currentrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]current().().is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().() {
278 self.bumprust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]bump().();
279 }
280 }
281 }
282 self.builderrust-analyzer cargo deb822-lossless 0.5.18 lossless/Parser#builder..finish_noderust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]finish_node().();
283 }
284
285 // Parse the colon
286 if self.currentrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]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#(COLONrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#COLON#) {
287 self.bumprust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]bump().();
288 self.skip_wsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]skip_ws().();
289 } else {
290 entry_has_errors = true;
291 self.builderrust-analyzer cargo deb822-lossless 0.5.18 lossless/Parser#builder..start_noderust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]start_node().(ERRORrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#ERROR#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
292
293 // Enhanced error recovery for missing colon
294 match self.currentrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]current().() {
295 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(VALUErust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#VALUE#) => {
296 self.add_positioned_errorrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]add_positioned_error().(
297 "missing colon ':' after field name".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(),
298 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("missing_colon".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()),
299 );
300 // Don't consume the value, let it be parsed as the field value
301 }
302 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(NEWLINErust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#NEWLINE#) => {
303 self.add_positioned_errorrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]add_positioned_error().(
304 "field name without value (missing colon and value)".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(),
305 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("incomplete_field".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()),
306 );
307 self.builderrust-analyzer cargo deb822-lossless 0.5.18 lossless/Parser#builder..finish_noderust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]finish_node().();
308 self.builderrust-analyzer cargo deb822-lossless 0.5.18 lossless/Parser#builder..finish_noderust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]finish_node().();
309 return;
310 }
311 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(KEYrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#KEY#) => {
312 self.add_positioned_errorrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]add_positioned_error().(
313 "field name followed by another field name (missing colon and value)"
314 .to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(),
315 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("consecutive_field_names".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()),
316 );
317 // Don't consume the next key, let it be parsed as a new entry
318 self.builderrust-analyzer cargo deb822-lossless 0.5.18 lossless/Parser#builder..finish_noderust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]finish_node().();
319 self.builderrust-analyzer cargo deb822-lossless 0.5.18 lossless/Parser#builder..finish_noderust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]finish_node().();
320 return;
321 }
322 _ => {
323 self.add_positioned_errorrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]add_positioned_error().(
324 formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("expected colon ':', got {:?}", self.currentrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]current().()),
325 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("missing_colon".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()),
326 );
327 if self.currentrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]current().().is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().() {
328 self.bumprust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]bump().();
329 }
330 }
331 }
332 self.builderrust-analyzer cargo deb822-lossless 0.5.18 lossless/Parser#builder..finish_noderust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]finish_node().();
333 }
334
335 // Parse the value (potentially multi-line)
336 loop {
337 while self.currentrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]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 deb822-lossless 0.5.18 lex/SyntaxKind#WHITESPACE#) || self.currentrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]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#(VALUErust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#VALUE#) {
338 self.bumprust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]bump().();
339 }
340
341 match self.currentrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]current().() {
342 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => {
343 break;
344 }
345 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(NEWLINErust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#NEWLINE#) => {
346 self.bumprust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]bump().();
347 }
348 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(KEYrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#KEY#) => {
349 // We've hit another field, this entry is complete
350 break;
351 }
352 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(g) => {
353 self.builderrust-analyzer cargo deb822-lossless 0.5.18 lossless/Parser#builder..start_noderust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]start_node().(ERRORrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#ERROR#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
354 self.add_positioned_errorrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]add_positioned_error().(
355 formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("unexpected token in field value: {g:?}"),
356 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("unexpected_value_token".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()),
357 );
358 self.bumprust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]bump().();
359 self.builderrust-analyzer cargo deb822-lossless 0.5.18 lossless/Parser#builder..finish_noderust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]finish_node().();
360 }
361 }
362
363 // Check for continuation lines or inline comments
364 if self.currentrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]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#(INDENTrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#INDENT#) {
365 self.bumprust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]bump().();
366 self.skip_wsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]skip_ws().();
367
368 // After indent and whitespace, we must have actual content (VALUE token)
369 // An empty continuation line (indent followed immediately by newline or EOF)
370 // is not valid according to Debian Policy
371 if self.currentrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]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 deb822-lossless 0.5.18 lex/SyntaxKind#NEWLINE#) || self.currentrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]current().().is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().() {
372 self.builderrust-analyzer cargo deb822-lossless 0.5.18 lossless/Parser#builder..start_noderust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]start_node().(ERRORrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#ERROR#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
373 self.add_positioned_errorrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]add_positioned_error().(
374 "empty continuation line (line with only whitespace)".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(),
375 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("empty_continuation_line".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()),
376 );
377 self.builderrust-analyzer cargo deb822-lossless 0.5.18 lossless/Parser#builder..finish_noderust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]finish_node().();
378 break;
379 }
380 } else if self.currentrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]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#(COMMENTrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#COMMENT#) {
381 // Comment line within a multi-line field value (e.g. commented-out
382 // continuation lines in Build-Depends). Consume the comment and
383 // continue looking for more continuation lines.
384 self.bumprust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]bump().();
385 } else {
386 break;
387 }
388 }
389
390 self.builderrust-analyzer cargo deb822-lossless 0.5.18 lossless/Parser#builder..finish_noderust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]finish_node().();
391
392 // If the entry had errors, we might want to recover
393 if entry_has_errors && !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().self.at_paragraph_startrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]at_paragraph_start().() && self.currentrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]current().().is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().() {
394 self.recover_entryrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]recover_entry().();
395 }
396 }
397
398 fn parse_paragraphrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]parse_paragraph().(&mut self) {
399 self.builderrust-analyzer cargo deb822-lossless 0.5.18 lossless/Parser#builder..start_noderust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]start_node().(PARAGRAPHrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#PARAGRAPH#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
400
401 let mut consecutive_errors = 0;
402 const MAX_CONSECUTIVE_ERRORSrust-analyzer cargo deb822-lossless 0.5.18 lossless/MAX_CONSECUTIVE_ERRORS.: usize = 5;
403
404 while self.currentrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]current().() 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().Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(NEWLINErust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#NEWLINE#) && self.currentrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]current().().is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().() {
405 let error_count_before = self.positioned_errorsrust-analyzer cargo deb822-lossless 0.5.18 lossless/Parser#positioned_errors..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().();
406
407 // Check if we're at a valid entry start
408 if self.currentrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]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#(KEYrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#KEY#) || self.currentrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]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#(COMMENTrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#COMMENT#) {
409 self.parse_entryrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]parse_entry().();
410
411 // Reset consecutive error count if we successfully parsed something
412 if self.positioned_errorsrust-analyzer cargo deb822-lossless 0.5.18 lossless/Parser#positioned_errors..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]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().error_count_before {
413 consecutive_errors = 0;
414 } else {
415 consecutive_errors rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().1;
416 }
417 } else {
418 // We're not at a valid entry start, this is an error
419 consecutive_errors rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().1;
420
421 self.builderrust-analyzer cargo deb822-lossless 0.5.18 lossless/Parser#builder..start_noderust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]start_node().(ERRORrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#ERROR#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
422 match self.currentrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]current().() {
423 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(VALUErust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#VALUE#) => {
424 self.add_positioned_errorrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]add_positioned_error().(
425 "orphaned text without field name".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(),
426 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("orphaned_text".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()),
427 );
428 // Consume the orphaned text
429 while self.currentrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]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#(VALUErust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#VALUE#)
430 || self.currentrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]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 deb822-lossless 0.5.18 lex/SyntaxKind#WHITESPACE#)
431 {
432 self.bumprust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]bump().();
433 }
434 }
435 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(COLONrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#COLON#) => {
436 self.add_positioned_errorrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]add_positioned_error().(
437 "orphaned colon without field name".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(),
438 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("orphaned_colon".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()),
439 );
440 self.bumprust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]bump().();
441 }
442 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(INDENTrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#INDENT#) => {
443 self.add_positioned_errorrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]add_positioned_error().(
444 "unexpected indentation without field".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(),
445 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("unexpected_indent".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()),
446 );
447 self.bumprust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]bump().();
448 }
449 _ => {
450 self.add_positioned_errorrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]add_positioned_error().(
451 formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!(
452 "unexpected token at paragraph level: {:?}",
453 self.currentrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]current().()
454 ),
455 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("unexpected_paragraph_token".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()),
456 );
457 self.bumprust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]bump().();
458 }
459 }
460 self.builderrust-analyzer cargo deb822-lossless 0.5.18 lossless/Parser#builder..finish_noderust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]finish_node().();
461 }
462
463 // If we have too many consecutive errors, skip to paragraph boundary
464 if consecutive_errors rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge().MAX_CONSECUTIVE_ERRORSrust-analyzer cargo deb822-lossless 0.5.18 lossless/MAX_CONSECUTIVE_ERRORS. {
465 self.add_positioned_errorrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]add_positioned_error().(
466 "too many consecutive parse errors, skipping to next paragraph".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(),
467 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("parse_recovery".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()),
468 );
469 self.skip_to_paragraph_boundaryrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]skip_to_paragraph_boundary().();
470 break;
471 }
472 }
473
474 self.builderrust-analyzer cargo deb822-lossless 0.5.18 lossless/Parser#builder..finish_noderust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]finish_node().();
475 }
476
477 fn parserust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]parse().(mut self) -> Parserust-analyzer cargo deb822-lossless 0.5.18 lossless/Parse# {
478 // Make sure that the root node covers all source
479 self.builderrust-analyzer cargo deb822-lossless 0.5.18 lossless/Parser#builder..start_noderust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]start_node().(ROOTrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#ROOT#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
480 while self.currentrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]current().().is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().() {
481 self.skip_ws_and_newlinesrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]skip_ws_and_newlines().();
482 if self.currentrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]current().().is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().() {
483 self.parse_paragraphrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]parse_paragraph().();
484 }
485 }
486 // Don't forget to eat *trailing* whitespace
487 self.skip_ws_and_newlinesrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]skip_ws_and_newlines().();
488 // Close the root node.
489 self.builderrust-analyzer cargo deb822-lossless 0.5.18 lossless/Parser#builder..finish_noderust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]finish_node().();
490
491 // Turn the builder into a GreenNode
492 Parserust-analyzer cargo deb822-lossless 0.5.18 lossless/Parse# {
493 green_noderust-analyzer cargo deb822-lossless 0.5.18 lossless/Parse#green_node.: self.builderrust-analyzer cargo deb822-lossless 0.5.18 lossless/Parser#builder..finishrust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]finish().(),
494 errorsrust-analyzer cargo deb822-lossless 0.5.18 lossless/Parse#errors.: self.errorsrust-analyzer cargo deb822-lossless 0.5.18 lossless/Parser#errors.,
495 positioned_errorsrust-analyzer cargo deb822-lossless 0.5.18 lossless/Parse#positioned_errors.: self.positioned_errorsrust-analyzer cargo deb822-lossless 0.5.18 lossless/Parser#positioned_errors.,
496 }
497 }
498 /// Advance one token, adding it to the current branch of the tree builder.
499 fn bumprust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]bump().(&mut self) {
500 let (kind, text) = self.tokensrust-analyzer cargo deb822-lossless 0.5.18 lossless/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().();
501 self.builderrust-analyzer cargo deb822-lossless 0.5.18 lossless/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);
502 self.current_token_indexrust-analyzer cargo deb822-lossless 0.5.18 lossless/Parser#current_token_index. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().1;
503 }
504 /// Peek at the first unprocessed token
505 fn currentrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]current().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<SyntaxKindrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#> {
506 self.tokensrust-analyzer cargo deb822-lossless 0.5.18 lossless/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)
507 }
508
509 /// Add a positioned error at the current position
510 fn add_positioned_errorrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]add_positioned_error().(&mut self, message: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, code: 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#>) {
511 let range = if self.current_token_indexrust-analyzer cargo deb822-lossless 0.5.18 lossless/Parser#current_token_index. 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().self.token_positionsrust-analyzer cargo deb822-lossless 0.5.18 lossless/Parser#token_positions..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().() {
512 let (_, start, end) = self.token_positionsrust-analyzer cargo deb822-lossless 0.5.18 lossless/Parser#token_positions.[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().self.current_token_indexrust-analyzer cargo deb822-lossless 0.5.18 lossless/Parser#current_token_index.]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().;
513 rowanrust-analyzer cargo rowan 0.16.1 crate/::TextRangerust-analyzer cargo text-size 1.1.1 range/TextRange#::newrust-analyzer cargo text-size 1.1.1 range/impl#[TextRange]new().(start, end)
514 } else {
515 // Default to end of text if no current token
516 let end = self
517 .token_positionsrust-analyzer cargo deb822-lossless 0.5.18 lossless/Parser#token_positions.
518 .lastrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]last().()
519 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|(_, _, end)| *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().end)
520 .unwrap_or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or_else().(|| rowanrust-analyzer cargo rowan 0.16.1 crate/::TextSizerust-analyzer cargo text-size 1.1.1 size/TextSize#::fromrust-analyzer cargo text-size 1.1.1 size/impl#[TextSize][`From<u32>`]from().(0));
521 rowanrust-analyzer cargo rowan 0.16.1 crate/::TextRangerust-analyzer cargo text-size 1.1.1 range/TextRange#::newrust-analyzer cargo text-size 1.1.1 range/impl#[TextRange]new().(end, end)
522 };
523
524 self.positioned_errorsrust-analyzer cargo deb822-lossless 0.5.18 lossless/Parser#positioned_errors..pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(PositionedParseErrorrust-analyzer cargo deb822-lossless 0.5.18 lossless/PositionedParseError# {
525 messagerust-analyzer cargo deb822-lossless 0.5.18 lossless/PositionedParseError#message.: message.clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][Clone]clone().(),
526 rangerust-analyzer cargo deb822-lossless 0.5.18 lossless/PositionedParseError#range.,
527 coderust-analyzer cargo deb822-lossless 0.5.18 lossless/PositionedParseError#code.,
528 });
529 self.errorsrust-analyzer cargo deb822-lossless 0.5.18 lossless/Parser#errors..pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(message);
530 }
531 fn skip_wsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]skip_ws().(&mut self) {
532 while self.currentrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]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 deb822-lossless 0.5.18 lex/SyntaxKind#WHITESPACE#) || self.currentrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]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#(COMMENTrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#COMMENT#) {
533 self.bumprust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]bump().()
534 }
535 }
536 fn skip_ws_and_newlinesrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]skip_ws_and_newlines().(&mut self) {
537 while self.currentrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]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 deb822-lossless 0.5.18 lex/SyntaxKind#WHITESPACE#)
538 || self.currentrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]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#(COMMENTrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#COMMENT#)
539 || self.currentrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]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 deb822-lossless 0.5.18 lex/SyntaxKind#NEWLINE#)
540 {
541 self.builderrust-analyzer cargo deb822-lossless 0.5.18 lossless/Parser#builder..start_noderust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]start_node().(EMPTY_LINErust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#EMPTY_LINE#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
542 while self.currentrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]current().() 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().Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(NEWLINErust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#NEWLINE#) && self.currentrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]current().().is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().() {
543 self.bumprust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]bump().();
544 }
545 if self.currentrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]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 deb822-lossless 0.5.18 lex/SyntaxKind#NEWLINE#) {
546 self.bumprust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]bump().();
547 }
548 self.builderrust-analyzer cargo deb822-lossless 0.5.18 lossless/Parser#builder..finish_noderust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]finish_node().();
549 }
550 }
551 }
552
553 let mut tokens = lexrust-analyzer cargo deb822-lossless 0.5.18 lex/lex().(text).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#<_>>();
554
555 // Build token positions in forward order
556 let mut token_positions = 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().();
557 let mut position = rowanrust-analyzer cargo rowan 0.16.1 crate/::TextSizerust-analyzer cargo text-size 1.1.1 size/TextSize#::fromrust-analyzer cargo text-size 1.1.1 size/impl#[TextSize][`From<u32>`]from().(0);
558 for (kind, text) in &tokens {
559 let start = position;
560 let end = start rust-analyzer cargo text-size 1.1.1 size/impl#[TextSize][`Add<Self>`]add().+rust-analyzer cargo text-size 1.1.1 size/impl#[TextSize][`Add<Self>`]add(). rust-analyzer cargo text-size 1.1.1 size/impl#[TextSize][`Add<Self>`]add().rowanrust-analyzer cargo rowan 0.16.1 crate/::TextSizerust-analyzer cargo text-size 1.1.1 size/TextSize#::ofrust-analyzer cargo text-size 1.1.1 size/impl#[TextSize]of().(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().text);
561 token_positions.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().((*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().kind, start, end));
562 position = end;
563 }
564
565 // Reverse tokens for parsing (but keep positions in forward order)
566 tokens.reverserust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]reverse().();
567 let current_token_index = 0;
568
569 Parserrust-analyzer cargo deb822-lossless 0.5.18 lossless/Parser# {
570 tokensrust-analyzer cargo deb822-lossless 0.5.18 lossless/Parser#tokens.,
571 builderrust-analyzer cargo deb822-lossless 0.5.18 lossless/Parser#builder.: GreenNodeBuilderrust-analyzer cargo rowan 0.16.1 green/builder/GreenNodeBuilder#::newrust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]new().(),
572 errorsrust-analyzer cargo deb822-lossless 0.5.18 lossless/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().(),
573 positioned_errorsrust-analyzer cargo deb822-lossless 0.5.18 lossless/Parser#positioned_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().(),
574 token_positionsrust-analyzer cargo deb822-lossless 0.5.18 lossless/Parser#token_positions.,
575 current_token_indexrust-analyzer cargo deb822-lossless 0.5.18 lossless/Parser#current_token_index.,
576 }
577 .parserust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`Parser<'a>`]parse().()
578 }
579
580 /// To work with the parse results we need a view into the
581 /// green tree - the Syntax tree.
582 /// It is also immutable, like a GreenNode,
583 /// but it contains parent pointers, offsets, and
584 /// has identity semantics.
585 type SyntaxNoderust-analyzer cargo deb822-lossless 0.5.18 lossless/SyntaxNode# = rowanrust-analyzer cargo rowan 0.16.1 crate/::SyntaxNoderust-analyzer cargo rowan 0.16.1 api/SyntaxNode#<Langrust-analyzer cargo deb822-lossless 0.5.18 lossless/Lang#>;
586 #[allow(unused)]
587 type SyntaxTokenrust-analyzer cargo deb822-lossless 0.5.18 lossless/SyntaxToken# = rowanrust-analyzer cargo rowan 0.16.1 crate/::SyntaxTokenrust-analyzer cargo rowan 0.16.1 api/SyntaxToken#<Langrust-analyzer cargo deb822-lossless 0.5.18 lossless/Lang#>;
588 #[allow(unused)]
589 type SyntaxElementrust-analyzer cargo deb822-lossless 0.5.18 lossless/SyntaxElement# = rowanrust-analyzer cargo rowan 0.16.1 crate/::NodeOrTokenrust-analyzer cargo rowan 0.16.1 utility_types/NodeOrToken#<SyntaxNoderust-analyzer cargo deb822-lossless 0.5.18 lossless/SyntaxNode#, SyntaxTokenrust-analyzer cargo deb822-lossless 0.5.18 lossless/SyntaxToken#>;
590
591 impl Parserust-analyzer cargo deb822-lossless 0.5.18 lossless/Parse# {
592 #[cfg(test)]
593 fn syntaxrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Parse]syntax().(&self) -> SyntaxNoderust-analyzer cargo deb822-lossless 0.5.18 lossless/SyntaxNode# {
594 SyntaxNoderust-analyzer cargo deb822-lossless 0.5.18 lossless/SyntaxNode#::new_rootrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]new_root().(self.green_noderust-analyzer cargo deb822-lossless 0.5.18 lossless/Parse#green_node..clonerust-analyzer cargo rowan 0.16.1 green/node/impl#[GreenNode][Clone]clone().())
595 }
596
597 fn root_mutrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Parse]root_mut().(&self) -> Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822# {
598 Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#::castrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]cast().(SyntaxNoderust-analyzer cargo deb822-lossless 0.5.18 lossless/SyntaxNode#::new_root_mutrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]new_root_mut().(self.green_noderust-analyzer cargo deb822-lossless 0.5.18 lossless/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().()
599 }
600 }
601
602 /// Structural equality on the green nodes of two syntax trees, with an
603 /// O(1) pointer-identity fast path.
604 ///
605 /// Returns true iff the two green trees are value-equal. When the underlying
606 /// `GreenNodeData` happens to share an address (typical after `snapshot()`
607 /// without intervening mutations) the comparison short-circuits in O(1);
608 /// otherwise it falls through to rowan's structural `PartialEq` on
609 /// `GreenNodeData`, which is O(n) in the worst case.
610 fn green_eqrust-analyzer cargo deb822-lossless 0.5.18 lossless/green_eq().(a: &SyntaxNoderust-analyzer cargo deb822-lossless 0.5.18 lossless/SyntaxNode#, b: &SyntaxNoderust-analyzer cargo deb822-lossless 0.5.18 lossless/SyntaxNode#) -> bool {
611 let a_green = a.greenrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]green().();
612 let b_green = b.greenrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]green().();
613 let a_ref: &rowanrust-analyzer cargo rowan 0.16.1 crate/::GreenNodeDatarust-analyzer cargo rowan 0.16.1 green/node/GreenNodeData# = &a_green;
614 let b_ref: &rowanrust-analyzer cargo rowan 0.16.1 crate/::GreenNodeDatarust-analyzer cargo rowan 0.16.1 green/node/GreenNodeData# = &b_green;
615 stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::ptrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/::eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/eq().(a_ref as *const _, b_ref as *const _) || a_ref rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().b_ref
616 }
617
618 /// Calculate line and column (both 0-indexed) for the given offset in the tree.
619 /// Column is measured in bytes from the start of the line.
620 fn line_col_at_offsetrust-analyzer cargo deb822-lossless 0.5.18 lossless/line_col_at_offset().(node: &SyntaxNoderust-analyzer cargo deb822-lossless 0.5.18 lossless/SyntaxNode#, offset: rowanrust-analyzer cargo rowan 0.16.1 crate/::TextSizerust-analyzer cargo text-size 1.1.1 size/TextSize#) -> (usize, usize) {
621 let root = node.ancestorsrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]ancestors().().lastrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#last().().unwrap_or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or_else().(|| node.clonerust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`][Clone]clone().());
622 let mut line = 0;
623 let mut last_newline_offset = rowanrust-analyzer cargo rowan 0.16.1 crate/::TextSizerust-analyzer cargo text-size 1.1.1 size/TextSize#::fromrust-analyzer cargo text-size 1.1.1 size/impl#[TextSize][`From<u32>`]from().(0);
624
625 for element in root.preorder_with_tokensrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]preorder_with_tokens().() {
626 if let rowanrust-analyzer cargo rowan 0.16.1 crate/::WalkEventrust-analyzer cargo rowan 0.16.1 utility_types/WalkEvent#::Enterrust-analyzer cargo rowan 0.16.1 utility_types/WalkEvent#Enter#(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)) = element {
627 if token.text_rangerust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxToken<L>`]text_range().().startrust-analyzer cargo text-size 1.1.1 range/impl#[TextRange]start().() 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().offset {
628 break;
629 }
630
631 // Count newlines and track position of last one
632 for (idx, _) in token.textrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxToken<L>`]text().().match_indicesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]match_indices().('\n') {
633 line rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().1;
634 last_newline_offset =
635 token.text_rangerust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxToken<L>`]text_range().().startrust-analyzer cargo text-size 1.1.1 range/impl#[TextRange]start().() rust-analyzer cargo text-size 1.1.1 size/impl#[TextSize][`Add<Self>`]add().+rust-analyzer cargo text-size 1.1.1 size/impl#[TextSize][`Add<Self>`]add(). rust-analyzer cargo text-size 1.1.1 size/impl#[TextSize][`Add<Self>`]add().rowanrust-analyzer cargo rowan 0.16.1 crate/::TextSizerust-analyzer cargo text-size 1.1.1 size/TextSize#::fromrust-analyzer cargo text-size 1.1.1 size/impl#[TextSize][`From<u32>`]from().((idx 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) as u32);
636 }
637 }
638 }
639
640 let column: usize = (offset rust-analyzer cargo text-size 1.1.1 size/impl#[TextSize][`Sub<Self>`]sub().-rust-analyzer cargo text-size 1.1.1 size/impl#[TextSize][`Sub<Self>`]sub(). rust-analyzer cargo text-size 1.1.1 size/impl#[TextSize][`Sub<Self>`]sub().last_newline_offset).intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().();
641 (line, column)
642 }
643
644 macro_rules! ast_noderust-analyzer cargo deb822-lossless 0.5.18 lossless/ast_node! {
645 ($ast:ident, $kind:ident) => {
646 #[doc = "An AST node representing a `"]
647 #[doc = stringify!($ast)]
648 #[doc = "`."]
649 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
650 #[repr(transparent)]
651 pub struct $ast(SyntaxNode);
652 impl $ast {
653 #[allow(unused)]
654 fn cast(node: SyntaxNode) -> Option<Self> {
655 if node.kind() == $kind {
656 Some(Self(node))
657 } else {
658 None
659 }
660 }
661
662 /// Get the line number (0-indexed) where this node starts.
663 pub fn line(&self) -> usize {
664 line_col_at_offset(&self.0, self.0.text_range().start()).0
665 }
666
667 /// Get the column number (0-indexed, in bytes) where this node starts.
668 pub fn column(&self) -> usize {
669 line_col_at_offset(&self.0, self.0.text_range().start()).1
670 }
671
672 /// Get both line and column (0-indexed) where this node starts.
673 /// Returns (line, column) where column is measured in bytes from the start of the line.
674 pub fn line_col(&self) -> (usize, usize) {
675 line_col_at_offset(&self.0, self.0.text_range().start())
676 }
677 }
678
679 impl AstNode for $ast {
680 type Language = Lang;
681
682 fn can_cast(kind: SyntaxKind) -> bool {
683 kind == $kind
684 }
685
686 fn cast(syntax: SyntaxNode) -> Option<Self> {
687 Self::cast(syntax)
688 }
689
690 fn syntax(&self) -> &SyntaxNode {
691 &self.0
692 }
693 }
694
695 impl std::fmt::Display for $ast {
696 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
697 write!(f, "{}", self.0.text())
698 }
699 }
700 };
701 }
702
703 ast_noderust-analyzer cargo deb822-lossless 0.5.18 lossless/ast_node!!(Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#, ROOTrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#ROOT#);
704 ast_noderust-analyzer cargo deb822-lossless 0.5.18 lossless/ast_node!!(Paragraphrust-analyzer cargo deb822-lossless 0.5.18 lossless/Paragraph#, PARAGRAPHrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#PARAGRAPH#);
705 ast_noderust-analyzer cargo deb822-lossless 0.5.18 lossless/ast_node!!(Entryrust-analyzer cargo deb822-lossless 0.5.18 lossless/Entry#, ENTRYrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#ENTRY#);
706
707 impl Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default# for Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822# {
708 fn defaultrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822][Default]default().() -> Selfrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822][Default] {
709 Selfrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822][Default]::newrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]new().()
710 }
711 }
712
713 impl Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822# {
714 /// Capture an independent snapshot of the current state.
715 ///
716 /// The returned value shares the underlying immutable [`rowan::GreenNode`]
717 /// data with `self` at the time of the call, but lives in its own mutable
718 /// tree: subsequent mutations to `self` do not propagate to the snapshot,
719 /// and vice versa. Pair with [`Self::tree_eq`] to detect whether
720 /// mutations have happened since the snapshot was taken.
721 ///
722 /// # Example
723 /// ```
724 /// use deb822_lossless::Deb822;
725 ///
726 /// let text = "Package: foo\n";
727 /// let deb822: Deb822 = text.parse().unwrap();
728 /// let snap = deb822.snapshot();
729 ///
730 /// let mut para = deb822.paragraphs().next().unwrap();
731 /// para.set("Package", "modified");
732 ///
733 /// let snap_para = snap.paragraphs().next().unwrap();
734 /// assert_eq!(snap_para.get("Package").as_deref(), Some("foo"));
735 /// ```
736 pub fn snapshotrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]snapshot().(&self) -> Selfrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822] {
737 Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#(SyntaxNoderust-analyzer cargo deb822-lossless 0.5.18 lossless/SyntaxNode#::new_root_mutrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]new_root_mut().(self.0rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#0..greenrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]green().().into_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/impl#[`Cow<'_, B>`]into_owned().()))
738 }
739
740 /// O(1) check: returns true iff `self` and `other` point to the same
741 /// underlying syntax tree instance.
742 ///
743 /// This is a pointer-identity check (not a value comparison). It is
744 /// useful with [`Self::snapshot`] to detect whether `self` has been
745 /// mutated since the snapshot was taken: every mutation produces a new
746 /// green tree, so `original.tree_eq(&snapshot)` flips from `true` to
747 /// `false` on the first mutation. Two independently-parsed trees with
748 /// identical contents are *not* `tree_eq`. For value equality, use
749 /// [`PartialEq`].
750 pub fn tree_eqrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]tree_eq().(&self, other: &Selfrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]) -> bool {
751 green_eqrust-analyzer cargo deb822-lossless 0.5.18 lossless/green_eq().(&self.0rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#0., &other.0rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#0.)
752 }
753
754 /// Create a new empty deb822 file.
755 pub fn newrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]new().() -> Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822# {
756 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().();
757
758 builder.start_noderust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]start_node().(ROOTrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#ROOT#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
759 builder.finish_noderust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]finish_node().();
760 Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#(SyntaxNoderust-analyzer cargo deb822-lossless 0.5.18 lossless/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().()))
761 }
762
763 /// Parse deb822 text, returning a Parse result
764 pub fn parserust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]parse().(text: &str) -> craterust-analyzer cargo deb822-lossless 0.5.18 crate/::Parserust-analyzer cargo deb822-lossless 0.5.18 parse/Parse#<Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#> {
765 craterust-analyzer cargo deb822-lossless 0.5.18 crate/::Parserust-analyzer cargo deb822-lossless 0.5.18 parse/Parse#::parse_deb822rust-analyzer cargo deb822-lossless 0.5.18 parse/impl#[`Parse<Deb822>`]parse_deb822().(text)
766 }
767
768 /// Provide a formatter that can handle indentation and trailing separators
769 ///
770 /// # Arguments
771 /// * `control` - The control file to format
772 /// * `indentation` - The indentation to use
773 /// * `immediate_empty_line` - Whether the value should always start with an empty line. If true,
774 /// then the result becomes something like "Field:\n value". This parameter
775 /// only applies to the values that will be formatted over more than one line.
776 /// * `max_line_length_one_liner` - If set, then this is the max length of the value
777 /// if it is crammed into a "one-liner" value. If the value(s) fit into
778 /// one line, this parameter will overrule immediate_empty_line.
779 /// * `sort_paragraphs` - If set, then this function will sort the paragraphs according to the
780 /// given function.
781 /// * `sort_entries` - If set, then this function will sort the entries according to the
782 /// given function.
783 #[must_use]
784 pub fn wrap_and_sortrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]wrap_and_sort().(
785 &self,
786 sort_paragraphs: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&dyn Fnrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/function/Fn#(&Paragraphrust-analyzer cargo deb822-lossless 0.5.18 lossless/Paragraph#, &Paragraphrust-analyzer cargo deb822-lossless 0.5.18 lossless/Paragraph#) -> 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#>,
787 wrap_and_sort_paragraph: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&dyn Fnrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/function/Fn#(&Paragraphrust-analyzer cargo deb822-lossless 0.5.18 lossless/Paragraph#) -> Paragraphrust-analyzer cargo deb822-lossless 0.5.18 lossless/Paragraph#>,
788 ) -> Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822# {
789 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().();
790 builder.start_noderust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]start_node().(ROOTrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#ROOT#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
791 let mut current = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![];
792 let mut paragraphs = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![];
793 for c in self.0rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#0..children_with_tokensrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]children_with_tokens().() {
794 match c.kindrust-analyzer cargo rowan 0.16.1 api/impl#[`NodeOrToken<SyntaxNode<L>, SyntaxToken<L>>`]kind().() {
795 PARAGRAPHrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#PARAGRAPH# => {
796 paragraphs.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().((
797 current,
798 Paragraphrust-analyzer cargo deb822-lossless 0.5.18 lossless/Paragraph#::castrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]cast().(c.as_noderust-analyzer cargo rowan 0.16.1 utility_types/impl#[`NodeOrToken<N, T>`]as_node().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().clonerust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`][Clone]clone().()).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(),
799 ));
800 current = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![];
801 }
802 COMMENTrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#COMMENT# | ERRORrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#ERROR# => {
803 current.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(c);
804 }
805 EMPTY_LINErust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#EMPTY_LINE# => {
806 current.extendrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Extend<T>`]extend().(
807 c.as_noderust-analyzer cargo rowan 0.16.1 utility_types/impl#[`NodeOrToken<N, T>`]as_node().()
808 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().()
809 .children_with_tokensrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]children_with_tokens().()
810 .skip_whilerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#skip_while().(|c| matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/matches!!(c.kindrust-analyzer cargo rowan 0.16.1 api/impl#[`NodeOrToken<SyntaxNode<L>, SyntaxToken<L>>`]kind().(), EMPTY_LINErust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#EMPTY_LINE# | NEWLINErust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#NEWLINE# | WHITESPACErust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#WHITESPACE#)),
811 );
812 }
813 _ => {}
814 }
815 }
816 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(sort_paragraph) = sort_paragraphs {
817 paragraphs.sort_byrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]sort_by().(|a, b| {
818 let a_key = &a.1;
819 let b_key = &b.1;
820 sort_paragraph(a_key, b_key)
821 });
822 }
823
824 for (i, paragraph) in paragraphs.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().() {
825 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 {
826 builder.start_noderust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]start_node().(EMPTY_LINErust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#EMPTY_LINE#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
827 builder.tokenrust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]token().(NEWLINErust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#NEWLINE#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), "\n");
828 builder.finish_noderust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]finish_node().();
829 }
830 for c in paragraph.0.into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().() {
831 builder.tokenrust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]token().(c.kindrust-analyzer cargo rowan 0.16.1 api/impl#[`NodeOrToken<SyntaxNode<L>, SyntaxToken<L>>`]kind().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), c.as_tokenrust-analyzer cargo rowan 0.16.1 utility_types/impl#[`NodeOrToken<N, T>`]as_token().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().textrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxToken<L>`]text().());
832 }
833 let new_paragraph = if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(ref ws) = wrap_and_sort_paragraph {
834 ws(&paragraph.1)
835 } else {
836 paragraph.1
837 };
838 injectrust-analyzer cargo deb822-lossless 0.5.18 lossless/inject().(&mut builder, new_paragraph.0rust-analyzer cargo deb822-lossless 0.5.18 lossless/Paragraph#0.);
839 }
840
841 for c in current {
842 builder.tokenrust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]token().(c.kindrust-analyzer cargo rowan 0.16.1 api/impl#[`NodeOrToken<SyntaxNode<L>, SyntaxToken<L>>`]kind().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), c.as_tokenrust-analyzer cargo rowan 0.16.1 utility_types/impl#[`NodeOrToken<N, T>`]as_token().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().textrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxToken<L>`]text().());
843 }
844
845 builder.finish_noderust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]finish_node().();
846 Selfrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822](SyntaxNoderust-analyzer cargo deb822-lossless 0.5.18 lossless/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().()))
847 }
848
849 /// Normalize the spacing around field separators (colons) for all entries in all paragraphs in place.
850 ///
851 /// This ensures that there is exactly one space after the colon and before the value
852 /// for each field in every paragraph. This is a lossless operation that preserves the
853 /// field names, values, and comments, but normalizes the whitespace formatting.
854 ///
855 /// # Examples
856 ///
857 /// ```
858 /// use deb822_lossless::Deb822;
859 /// use std::str::FromStr;
860 ///
861 /// let input = "Field1: value1\nField2:value2\n\nField3: value3\n";
862 /// let mut deb822 = Deb822::from_str(input).unwrap();
863 ///
864 /// deb822.normalize_field_spacing();
865 /// assert_eq!(deb822.to_string(), "Field1: value1\nField2: value2\n\nField3: value3\n");
866 /// ```
867 pub fn normalize_field_spacingrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]normalize_field_spacing().(&mut self) -> bool {
868 let mut any_changed = false;
869
870 // Collect paragraphs to avoid borrowing issues
871 let mut paragraphs: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_> = self.paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraphs().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().();
872
873 // Normalize each paragraph
874 for para in &mut paragraphs {
875 if para.normalize_field_spacingrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]normalize_field_spacing().() {
876 any_changed = true;
877 }
878 }
879
880 any_changed
881 }
882
883 /// Returns an iterator over all paragraphs in the file.
884 pub fn paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraphs().(&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# = Paragraphrust-analyzer cargo deb822-lossless 0.5.18 lossless/Paragraph#> {
885 self.0rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#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().(Paragraphrust-analyzer cargo deb822-lossless 0.5.18 lossless/Paragraph#::castrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]cast().)
886 }
887
888 /// Returns paragraphs that intersect with the given text range.
889 ///
890 /// A paragraph is included if its text range overlaps with the provided range.
891 ///
892 /// # Arguments
893 ///
894 /// * `range` - The text range to query
895 ///
896 /// # Returns
897 ///
898 /// An iterator over paragraphs that intersect with the range
899 ///
900 /// # Examples
901 ///
902 /// ```
903 /// use deb822_lossless::{Deb822, TextRange};
904 ///
905 /// let input = "Package: foo\n\nPackage: bar\n\nPackage: baz\n";
906 /// let deb822 = Deb822::parse(input).tree();
907 ///
908 /// // Query paragraphs in the first half of the document
909 /// let range = TextRange::new(0.into(), 20.into());
910 /// let paras: Vec<_> = deb822.paragraphs_in_range(range).collect();
911 /// assert!(paras.len() >= 1);
912 /// ```
913 pub fn paragraphs_in_rangerust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraphs_in_range().(
914 &self,
915 range: rowanrust-analyzer cargo rowan 0.16.1 crate/::TextRangerust-analyzer cargo text-size 1.1.1 range/TextRange#,
916 ) -> 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# = Paragraphrust-analyzer cargo deb822-lossless 0.5.18 lossless/Paragraph#> + '_ {
917 self.paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraphs().().filterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#filter().(move |p| {
918 let para_range = p.text_rangerust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]text_range().();
919 // Check if ranges overlap: para starts before range ends AND para ends after range starts
920 para_range.startrust-analyzer cargo text-size 1.1.1 range/impl#[TextRange]start().() 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().range.endrust-analyzer cargo text-size 1.1.1 range/impl#[TextRange]end().() && para_range.endrust-analyzer cargo text-size 1.1.1 range/impl#[TextRange]end().() 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().range.startrust-analyzer cargo text-size 1.1.1 range/impl#[TextRange]start().()
921 })
922 }
923
924 /// Find the paragraph that contains the given text offset.
925 ///
926 /// # Arguments
927 ///
928 /// * `offset` - The text offset to query
929 ///
930 /// # Returns
931 ///
932 /// The paragraph containing the offset, or None if no paragraph contains it
933 ///
934 /// # Examples
935 ///
936 /// ```
937 /// use deb822_lossless::{Deb822, TextSize};
938 ///
939 /// let input = "Package: foo\n\nPackage: bar\n";
940 /// let deb822 = Deb822::parse(input).tree();
941 ///
942 /// // Find paragraph at offset 5 (within first paragraph)
943 /// let para = deb822.paragraph_at_position(TextSize::from(5));
944 /// assert!(para.is_some());
945 /// ```
946 pub fn paragraph_at_positionrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraph_at_position().(&self, offset: rowanrust-analyzer cargo rowan 0.16.1 crate/::TextSizerust-analyzer cargo text-size 1.1.1 size/TextSize#) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Paragraphrust-analyzer cargo deb822-lossless 0.5.18 lossless/Paragraph#> {
947 self.paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraphs().().findrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#find().(|p| {
948 let range = p.text_rangerust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]text_range().();
949 range.containsrust-analyzer cargo text-size 1.1.1 range/impl#[TextRange]contains().(offset)
950 })
951 }
952
953 /// Find the paragraph at the given line number (0-indexed).
954 ///
955 /// # Arguments
956 ///
957 /// * `line` - The line number to query (0-indexed)
958 ///
959 /// # Returns
960 ///
961 /// The paragraph at the given line, or None if no paragraph is at that line
962 ///
963 /// # Examples
964 ///
965 /// ```
966 /// use deb822_lossless::Deb822;
967 ///
968 /// let input = "Package: foo\nVersion: 1.0\n\nPackage: bar\n";
969 /// let deb822 = Deb822::parse(input).tree();
970 ///
971 /// // Find paragraph at line 0
972 /// let para = deb822.paragraph_at_line(0);
973 /// assert!(para.is_some());
974 /// ```
975 pub fn paragraph_at_linerust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraph_at_line().(&self, line: usize) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Paragraphrust-analyzer cargo deb822-lossless 0.5.18 lossless/Paragraph#> {
976 self.paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraphs().().findrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#find().(|p| {
977 let start_line = p.linerust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]line().();
978 let range = p.text_rangerust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]text_range().();
979 let text_str = self.0rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#0..textrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]text().().to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().();
980 let text_before_end = &text_str[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`Index<I>`]index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeTo#range.endrust-analyzer cargo text-size 1.1.1 range/impl#[TextRange]end().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`Index<I>`]index().;
981 let end_line = text_before_end.linesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]lines().().countrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#count().().saturating_subrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[usize]saturating_sub().(1);
982 line rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge().start_line && line rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le().<=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le().end_line
983 })
984 }
985
986 /// Find the entry at the given line and column position.
987 ///
988 /// # Arguments
989 ///
990 /// * `line` - The line number (0-indexed)
991 /// * `col` - The column number (0-indexed)
992 ///
993 /// # Returns
994 ///
995 /// The entry at the given position, or None if no entry is at that position
996 ///
997 /// # Examples
998 ///
999 /// ```
1000 /// use deb822_lossless::Deb822;
1001 ///
1002 /// let input = "Package: foo\nVersion: 1.0\n";
1003 /// let deb822 = Deb822::parse(input).tree();
1004 ///
1005 /// // Find entry at line 0, column 0
1006 /// let entry = deb822.entry_at_line_col(0, 0);
1007 /// assert!(entry.is_some());
1008 /// ```
1009 pub fn entry_at_line_colrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]entry_at_line_col().(&self, line: usize, col: usize) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Entryrust-analyzer cargo deb822-lossless 0.5.18 lossless/Entry#> {
1010 // Convert line/col to text offset
1011 let text_str = self.0rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#0..textrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]text().().to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().();
1012 let offset: usize = text_str.linesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]lines().().takerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#take().(line).maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|l| l.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]len().() 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).sumrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#sum().();
1013 let position = rowanrust-analyzer cargo rowan 0.16.1 crate/::TextSizerust-analyzer cargo text-size 1.1.1 size/TextSize#::fromrust-analyzer cargo text-size 1.1.1 size/impl#[TextSize][`From<u32>`]from().((offset 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().col) as u32);
1014
1015 // Find the entry that contains this position
1016 for para in self.paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraphs().() {
1017 for entry in para.entriesrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]entries().() {
1018 let range = entry.text_rangerust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]text_range().();
1019 if range.containsrust-analyzer cargo text-size 1.1.1 range/impl#[TextRange]contains().(position) {
1020 return Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(entry);
1021 }
1022 }
1023 }
1024 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#
1025 }
1026
1027 /// Converts the perceptual paragraph index to the node index.
1028 fn convert_indexrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]convert_index().(&self, index: usize) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<usize> {
1029 let mut current_pos = 0usize;
1030 if index 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 {
1031 return Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(0);
1032 }
1033 for (i, node) in self.0rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#0..children_with_tokensrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]children_with_tokens().().enumeraterust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#enumerate().() {
1034 if node.kindrust-analyzer cargo rowan 0.16.1 api/impl#[`NodeOrToken<SyntaxNode<L>, SyntaxToken<L>>`]kind().() rust-analyzer cargo deb822-lossless 0.5.18 lex/impl#[SyntaxKind][`PartialEq<Self>`]eq().==rust-analyzer cargo deb822-lossless 0.5.18 lex/impl#[SyntaxKind][`PartialEq<Self>`]eq(). rust-analyzer cargo deb822-lossless 0.5.18 lex/impl#[SyntaxKind][`PartialEq<Self>`]eq().PARAGRAPHrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#PARAGRAPH# {
1035 if current_pos 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().index {
1036 return Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(i);
1037 }
1038 current_pos rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().1;
1039 }
1040 }
1041
1042 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#
1043 }
1044
1045 /// Delete trailing empty lines after specified node and before any non-empty line nodes.
1046 fn delete_trailing_spacerust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]delete_trailing_space().(&self, start: usize) {
1047 for (i, node) in self.0rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#0..children_with_tokensrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]children_with_tokens().().enumeraterust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#enumerate().() {
1048 if i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().start {
1049 continue;
1050 }
1051 if node.kindrust-analyzer cargo rowan 0.16.1 api/impl#[`NodeOrToken<SyntaxNode<L>, SyntaxToken<L>>`]kind().() 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().EMPTY_LINErust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#EMPTY_LINE# {
1052 return;
1053 }
1054 // this is not a typo, the index will shift by one after deleting the node
1055 // so instead of deleting using `i`, we use `start` as the start index
1056 self.0rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#0..splice_childrenrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]splice_children().(start..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#start 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, []);
1057 }
1058 }
1059
1060 /// Shared internal function to insert a new paragraph into the file.
1061 fn insert_empty_paragraphrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]insert_empty_paragraph().(&mut self, index: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<usize>) -> Paragraphrust-analyzer cargo deb822-lossless 0.5.18 lossless/Paragraph# {
1062 let paragraph = Paragraphrust-analyzer cargo deb822-lossless 0.5.18 lossless/Paragraph#::newrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]new().();
1063 let mut to_insert = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![];
1064 if self.0rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#0..childrenrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]children().().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][`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 {
1065 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().();
1066 builder.start_noderust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]start_node().(EMPTY_LINErust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#EMPTY_LINE#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
1067 builder.tokenrust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]token().(NEWLINErust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#NEWLINE#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), "\n");
1068 builder.finish_noderust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]finish_node().();
1069 to_insert.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(SyntaxNoderust-analyzer cargo deb822-lossless 0.5.18 lossless/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().());
1070 }
1071 to_insert.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(paragraph.0rust-analyzer cargo deb822-lossless 0.5.18 lossless/Paragraph#0..clonerust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`][Clone]clone().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
1072 let insertion_point = match index {
1073 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(i) => {
1074 if to_insert.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>`]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().1 {
1075 to_insert.swaprust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]swap().(0, 1);
1076 }
1077 i
1078 }
1079 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => self.0rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#0..childrenrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]children().().countrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#count().(),
1080 };
1081 self.0rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#0.
1082 .splice_childrenrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]splice_children().(insertion_point..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#insertion_point, to_insert);
1083 paragraph
1084 }
1085
1086 /// Insert a new empty paragraph into the file after specified index.
1087 ///
1088 /// # Examples
1089 ///
1090 /// ```
1091 /// use deb822_lossless::{Deb822, Paragraph};
1092 /// let mut d: Deb822 = vec![
1093 /// vec![("Foo", "Bar"), ("Baz", "Qux")].into_iter().collect(),
1094 /// vec![("A", "B"), ("C", "D")].into_iter().collect(),
1095 /// ]
1096 /// .into_iter()
1097 /// .collect();
1098 /// let mut p = d.insert_paragraph(0);
1099 /// p.set("Foo", "Baz");
1100 /// assert_eq!(d.to_string(), "Foo: Baz\n\nFoo: Bar\nBaz: Qux\n\nA: B\nC: D\n");
1101 /// let mut another = d.insert_paragraph(1);
1102 /// another.set("Y", "Z");
1103 /// assert_eq!(d.to_string(), "Foo: Baz\n\nY: Z\n\nFoo: Bar\nBaz: Qux\n\nA: B\nC: D\n");
1104 /// ```
1105 pub fn insert_paragraphrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]insert_paragraph().(&mut self, index: usize) -> Paragraphrust-analyzer cargo deb822-lossless 0.5.18 lossless/Paragraph# {
1106 self.insert_empty_paragraphrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]insert_empty_paragraph().(self.convert_indexrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]convert_index().(index))
1107 }
1108
1109 /// Remove the paragraph at the specified index from the file.
1110 ///
1111 /// # Examples
1112 ///
1113 /// ```
1114 /// use deb822_lossless::Deb822;
1115 /// let mut d: Deb822 = vec![
1116 /// vec![("Foo", "Bar"), ("Baz", "Qux")].into_iter().collect(),
1117 /// vec![("A", "B"), ("C", "D")].into_iter().collect(),
1118 /// ]
1119 /// .into_iter()
1120 /// .collect();
1121 /// d.remove_paragraph(0);
1122 /// assert_eq!(d.to_string(), "A: B\nC: D\n");
1123 /// d.remove_paragraph(0);
1124 /// assert_eq!(d.to_string(), "");
1125 /// ```
1126 pub fn remove_paragraphrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]remove_paragraph().(&mut self, index: usize) {
1127 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(index) = self.convert_indexrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]convert_index().(index) {
1128 self.0rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#0..splice_childrenrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]splice_children().(index..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#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, []);
1129 self.delete_trailing_spacerust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]delete_trailing_space().(index);
1130 }
1131 }
1132
1133 /// Move a paragraph from one index to another.
1134 ///
1135 /// This moves the paragraph at `from_index` to `to_index`, shifting other paragraphs as needed.
1136 /// If `from_index` equals `to_index`, no operation is performed.
1137 ///
1138 /// # Examples
1139 ///
1140 /// ```
1141 /// use deb822_lossless::Deb822;
1142 /// let mut d: Deb822 = vec![
1143 /// vec![("Foo", "Bar"), ("Baz", "Qux")].into_iter().collect(),
1144 /// vec![("A", "B"), ("C", "D")].into_iter().collect(),
1145 /// vec![("X", "Y"), ("Z", "W")].into_iter().collect(),
1146 /// ]
1147 /// .into_iter()
1148 /// .collect();
1149 /// d.move_paragraph(0, 2);
1150 /// assert_eq!(d.to_string(), "A: B\nC: D\n\nX: Y\nZ: W\n\nFoo: Bar\nBaz: Qux\n");
1151 /// ```
1152 pub fn move_paragraphrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]move_paragraph().(&mut self, from_index: usize, to_index: usize) {
1153 if from_index 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().to_index {
1154 return;
1155 }
1156
1157 // Get the paragraph count to validate indices
1158 let paragraph_count = self.paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraphs().().countrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#count().();
1159 if from_index rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge().paragraph_count || to_index rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge().paragraph_count {
1160 return;
1161 }
1162
1163 // Clone the paragraph node we want to move
1164 let paragraph_to_move = self.paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraphs().().nthrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#nth().(from_index).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().0rust-analyzer cargo deb822-lossless 0.5.18 lossless/Paragraph#0..clonerust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`][Clone]clone().();
1165
1166 // Remove the paragraph from its original position
1167 let from_physical = self.convert_indexrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]convert_index().(from_index).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().();
1168
1169 // Determine the range to remove (paragraph and possibly preceding EMPTY_LINE)
1170 let mut start_idx = from_physical;
1171 if from_physical 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 {
1172 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(prev_node) = self.0rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#0..children_with_tokensrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]children_with_tokens().().nthrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#nth().(from_physical rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().1) {
1173 if prev_node.kindrust-analyzer cargo rowan 0.16.1 api/impl#[`NodeOrToken<SyntaxNode<L>, SyntaxToken<L>>`]kind().() rust-analyzer cargo deb822-lossless 0.5.18 lex/impl#[SyntaxKind][`PartialEq<Self>`]eq().==rust-analyzer cargo deb822-lossless 0.5.18 lex/impl#[SyntaxKind][`PartialEq<Self>`]eq(). rust-analyzer cargo deb822-lossless 0.5.18 lex/impl#[SyntaxKind][`PartialEq<Self>`]eq().EMPTY_LINErust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#EMPTY_LINE# {
1174 start_idx = from_physical rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().1;
1175 }
1176 }
1177 }
1178
1179 // Remove the paragraph and any preceding EMPTY_LINE
1180 self.0rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#0..splice_childrenrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]splice_children().(start_idx..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#from_physical 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, []);
1181 self.delete_trailing_spacerust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]delete_trailing_space().(start_idx);
1182
1183 // Calculate the physical insertion point
1184 // After removal, we need to determine where to insert
1185 // The semantics are: the moved paragraph ends up at logical index to_index in the final result
1186 let insert_at = if to_index 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().from_index {
1187 // Moving forward: after removal, to_index-1 paragraphs should be before the moved one
1188 // So we insert after paragraph at index (to_index - 1)
1189 let target_idx = to_index rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().1;
1190 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(target_physical) = self.convert_indexrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]convert_index().(target_idx) {
1191 target_physical 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
1192 } else {
1193 // If convert_index returns None, insert at the end
1194 self.0rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#0..childrenrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]children().().countrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#count().()
1195 }
1196 } else {
1197 // Moving backward: after removal, to_index paragraphs should be before the moved one
1198 // So we insert at paragraph index to_index
1199 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(target_physical) = self.convert_indexrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]convert_index().(to_index) {
1200 target_physical
1201 } else {
1202 self.0rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#0..childrenrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]children().().countrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#count().()
1203 }
1204 };
1205
1206 // Build the nodes to insert
1207 let mut to_insert = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![];
1208
1209 // Determine if we need to add an EMPTY_LINE before the paragraph
1210 let needs_empty_line_before = if insert_at 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 {
1211 // At the beginning - no empty line before
1212 false
1213 } else if insert_at 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 {
1214 // Check if there's already an EMPTY_LINE at the insertion point
1215 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(node_at_insert) = self.0rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#0..children_with_tokensrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]children_with_tokens().().nthrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#nth().(insert_at rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().1) {
1216 node_at_insert.kindrust-analyzer cargo rowan 0.16.1 api/impl#[`NodeOrToken<SyntaxNode<L>, SyntaxToken<L>>`]kind().() 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().EMPTY_LINErust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#EMPTY_LINE#
1217 } else {
1218 false
1219 }
1220 } else {
1221 false
1222 };
1223
1224 if needs_empty_line_before {
1225 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().();
1226 builder.start_noderust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]start_node().(EMPTY_LINErust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#EMPTY_LINE#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
1227 builder.tokenrust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]token().(NEWLINErust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#NEWLINE#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), "\n");
1228 builder.finish_noderust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]finish_node().();
1229 to_insert.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(SyntaxNoderust-analyzer cargo deb822-lossless 0.5.18 lossless/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().());
1230 }
1231
1232 to_insert.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(paragraph_to_move.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
1233
1234 // Determine if we need to add an EMPTY_LINE after the paragraph
1235 let needs_empty_line_after = if insert_at 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().self.0rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#0..childrenrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]children().().countrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#count().() {
1236 // There are nodes after - check if next node is EMPTY_LINE
1237 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(node_after) = self.0rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#0..children_with_tokensrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]children_with_tokens().().nthrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#nth().(insert_at) {
1238 node_after.kindrust-analyzer cargo rowan 0.16.1 api/impl#[`NodeOrToken<SyntaxNode<L>, SyntaxToken<L>>`]kind().() 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().EMPTY_LINErust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#EMPTY_LINE#
1239 } else {
1240 false
1241 }
1242 } else {
1243 false
1244 };
1245
1246 if needs_empty_line_after {
1247 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().();
1248 builder.start_noderust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]start_node().(EMPTY_LINErust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#EMPTY_LINE#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
1249 builder.tokenrust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]token().(NEWLINErust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#NEWLINE#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), "\n");
1250 builder.finish_noderust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]finish_node().();
1251 to_insert.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(SyntaxNoderust-analyzer cargo deb822-lossless 0.5.18 lossless/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().());
1252 }
1253
1254 // Insert at the new position
1255 self.0rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#0..splice_childrenrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]splice_children().(insert_at..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#insert_at, to_insert);
1256 }
1257
1258 /// Add a new empty paragraph to the end of the file.
1259 pub fn add_paragraphrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]add_paragraph().(&mut self) -> Paragraphrust-analyzer cargo deb822-lossless 0.5.18 lossless/Paragraph# {
1260 self.insert_empty_paragraphrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]insert_empty_paragraph().(Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#)
1261 }
1262
1263 /// Swap two paragraphs by their indices.
1264 ///
1265 /// This method swaps the positions of two paragraphs while preserving their
1266 /// content, formatting, whitespace, and comments. The paragraphs at positions
1267 /// `index1` and `index2` will exchange places.
1268 ///
1269 /// # Arguments
1270 ///
1271 /// * `index1` - The index of the first paragraph to swap
1272 /// * `index2` - The index of the second paragraph to swap
1273 ///
1274 /// # Panics
1275 ///
1276 /// Panics if either `index1` or `index2` is out of bounds.
1277 ///
1278 /// # Examples
1279 ///
1280 /// ```
1281 /// use deb822_lossless::Deb822;
1282 /// let mut d: Deb822 = vec![
1283 /// vec![("Foo", "Bar")].into_iter().collect(),
1284 /// vec![("A", "B")].into_iter().collect(),
1285 /// vec![("X", "Y")].into_iter().collect(),
1286 /// ]
1287 /// .into_iter()
1288 /// .collect();
1289 /// d.swap_paragraphs(0, 2);
1290 /// assert_eq!(d.to_string(), "X: Y\n\nA: B\n\nFoo: Bar\n");
1291 /// ```
1292 pub fn swap_paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]swap_paragraphs().(&mut self, index1: usize, index2: usize) {
1293 if index1 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().index2 {
1294 return;
1295 }
1296
1297 // Collect all children
1298 let mut children: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_> = self.0rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#0..childrenrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]children().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|n| n.clonerust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`][Clone]clone().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().();
1299
1300 // Find the child indices for paragraphs
1301 let mut para_child_indices = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![];
1302 for (child_idx, child) in self.0rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#0..childrenrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]children().().enumeraterust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#enumerate().() {
1303 if child.kindrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]kind().() rust-analyzer cargo deb822-lossless 0.5.18 lex/impl#[SyntaxKind][`PartialEq<Self>`]eq().==rust-analyzer cargo deb822-lossless 0.5.18 lex/impl#[SyntaxKind][`PartialEq<Self>`]eq(). rust-analyzer cargo deb822-lossless 0.5.18 lex/impl#[SyntaxKind][`PartialEq<Self>`]eq().PARAGRAPHrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#PARAGRAPH# {
1304 para_child_indices.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(child_idx);
1305 }
1306 }
1307
1308 // Validate paragraph indices
1309 if index1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge().para_child_indices.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().() {
1310 panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("index1 {} out of bounds", index1);
1311 }
1312 if index2 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge().para_child_indices.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().() {
1313 panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("index2 {} out of bounds", index2);
1314 }
1315
1316 let child_idx1 = para_child_indices[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().index1]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().;
1317 let child_idx2 = para_child_indices[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().index2]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().;
1318
1319 // Swap the children in the vector
1320 children.swaprust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]swap().(child_idx1, child_idx2);
1321
1322 // Replace all children
1323 let num_children = children.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().();
1324 self.0rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#0..splice_childrenrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]splice_children().(0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#num_children, children);
1325 }
1326
1327 /// Read a deb822 file from the given path.
1328 pub fn from_filerust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]from_file().(path: impl AsRefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#<Pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#>) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822], Errorrust-analyzer cargo deb822-lossless 0.5.18 lossless/Error#> {
1329 let text = stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/::read_to_stringrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/read_to_string().(path)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
1330 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]::from_strrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822][FromStr]from_str().(&text)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().)
1331 }
1332
1333 /// Read a deb822 file from the given path, ignoring any syntax errors.
1334 pub fn from_file_relaxedrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]from_file_relaxed().(
1335 path: impl AsRefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#<Pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#>,
1336 ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(Selfrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822], 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#>), 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#> {
1337 let text = stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/::read_to_stringrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/read_to_string().(path)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
1338 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]::from_str_relaxedrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]from_str_relaxed().(&text))
1339 }
1340
1341 /// Parse a deb822 file from a string, allowing syntax errors.
1342 pub fn from_str_relaxedrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]from_str_relaxed().(s: &str) -> (Selfrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822], 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#>) {
1343 let parsed = parserust-analyzer cargo deb822-lossless 0.5.18 lossless/parse().(s);
1344 (parsed.root_mutrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Parse]root_mut().(), parsed.errorsrust-analyzer cargo deb822-lossless 0.5.18 lossless/Parse#errors.)
1345 }
1346
1347 /// Read a deb822 file from a Read object.
1348 pub fn readrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]read().<R: 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/::Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#>(mut r: R) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822], Errorrust-analyzer cargo deb822-lossless 0.5.18 lossless/Error#> {
1349 let mut buf = Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]new().();
1350 r.read_to_stringrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#read_to_string().(&mut buf)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
1351 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]::from_strrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822][FromStr]from_str().(&buf)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().)
1352 }
1353
1354 /// Read a deb822 file from a Read object, allowing syntax errors.
1355 pub fn read_relaxedrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]read_relaxed().<R: 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/::Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#>(mut r: R) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(Selfrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822], 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#>), 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#> {
1356 let mut buf = Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]new().();
1357 r.read_to_stringrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#read_to_string().(&mut buf)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
1358 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]::from_str_relaxedrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]from_str_relaxed().(&buf))
1359 }
1360 }
1361
1362 fn injectrust-analyzer cargo deb822-lossless 0.5.18 lossless/inject().(builder: &mut GreenNodeBuilderrust-analyzer cargo rowan 0.16.1 green/builder/GreenNodeBuilder#, node: SyntaxNoderust-analyzer cargo deb822-lossless 0.5.18 lossless/SyntaxNode#) {
1363 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().());
1364 for child in node.children_with_tokensrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]children_with_tokens().() {
1365 match child {
1366 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) => {
1367 injectrust-analyzer cargo deb822-lossless 0.5.18 lossless/inject().(builder, child);
1368 }
1369 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) => {
1370 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().());
1371 }
1372 }
1373 }
1374 builder.finish_noderust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]finish_node().();
1375 }
1376
1377 impl FromIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/FromIterator#<Paragraphrust-analyzer cargo deb822-lossless 0.5.18 lossless/Paragraph#> for Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822# {
1378 fn from_iterrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822][`FromIterator<Paragraph>`]from_iter().<T: IntoIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#Item# = Paragraphrust-analyzer cargo deb822-lossless 0.5.18 lossless/Paragraph#>>(iter: T) -> Selfrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822][`FromIterator<Paragraph>`] {
1379 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().();
1380 builder.start_noderust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]start_node().(ROOTrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#ROOT#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
1381 for (i, paragraph) in iter.into_iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#into_iter().().enumeraterust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#enumerate().() {
1382 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 {
1383 builder.start_noderust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]start_node().(EMPTY_LINErust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#EMPTY_LINE#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
1384 builder.tokenrust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]token().(NEWLINErust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#NEWLINE#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), "\n");
1385 builder.finish_noderust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]finish_node().();
1386 }
1387 injectrust-analyzer cargo deb822-lossless 0.5.18 lossless/inject().(&mut builder, paragraph.0rust-analyzer cargo deb822-lossless 0.5.18 lossless/Paragraph#0.);
1388 }
1389 builder.finish_noderust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]finish_node().();
1390 Selfrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822][`FromIterator<Paragraph>`](SyntaxNoderust-analyzer cargo deb822-lossless 0.5.18 lossless/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().()))
1391 }
1392 }
1393
1394 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#<(Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#)>> for Paragraphrust-analyzer cargo deb822-lossless 0.5.18 lossless/Paragraph# {
1395 fn fromrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph][`From<Vec<(String, String)>>`]from().(v: 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#, Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#)>) -> Selfrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph][`From<Vec<(String, String)>>`] {
1396 v.into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().()
1397 }
1398 }
1399
1400 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#<(&str, &str)>> for Paragraphrust-analyzer cargo deb822-lossless 0.5.18 lossless/Paragraph# {
1401 fn fromrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph][`From<Vec<(&str, &str)>>`]from().(v: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<(&str, &str)>) -> Selfrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph][`From<Vec<(&str, &str)>>`] {
1402 v.into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().()
1403 }
1404 }
1405
1406 impl FromIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/FromIterator#<(Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#)> for Paragraphrust-analyzer cargo deb822-lossless 0.5.18 lossless/Paragraph# {
1407 fn from_iterrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph][`FromIterator<(String, String)>`]from_iter().<T: IntoIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#Item# = (Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#)>>(iter: T) -> Selfrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph][`FromIterator<(String, String)>`] {
1408 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().();
1409 builder.start_noderust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]start_node().(PARAGRAPHrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#PARAGRAPH#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
1410 for (key, value) in iter {
1411 builder.start_noderust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]start_node().(ENTRYrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#ENTRY#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
1412 builder.tokenrust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]token().(KEYrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#KEY#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), &key);
1413 builder.tokenrust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]token().(COLONrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#COLON#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), ":");
1414 builder.tokenrust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]token().(WHITESPACErust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#WHITESPACE#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), " ");
1415 for (i, line) in value.splitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]split().('\n').enumeraterust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#enumerate().() {
1416 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 {
1417 builder.tokenrust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]token().(INDENTrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#INDENT#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), " ");
1418 }
1419 builder.tokenrust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]token().(VALUErust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#VALUE#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), line);
1420 builder.tokenrust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]token().(NEWLINErust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#NEWLINE#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), "\n");
1421 }
1422 builder.finish_noderust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]finish_node().();
1423 }
1424 builder.finish_noderust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]finish_node().();
1425 Selfrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph][`FromIterator<(String, String)>`](SyntaxNoderust-analyzer cargo deb822-lossless 0.5.18 lossless/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().()))
1426 }
1427 }
1428
1429 impl<'a> FromIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/FromIterator#<(&'a str, &'a str)> for Paragraphrust-analyzer cargo deb822-lossless 0.5.18 lossless/Paragraph# {
1430 fn from_iterrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph][`FromIterator<(&'a str, &'a str)>`]from_iter().<T: IntoIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#Item# = (&'a str, &'a str)>>(iter: T) -> Selfrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph][`FromIterator<(&'a str, &'a str)>`] {
1431 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().();
1432 builder.start_noderust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]start_node().(PARAGRAPHrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#PARAGRAPH#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
1433 for (key, value) in iter {
1434 builder.start_noderust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]start_node().(ENTRYrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#ENTRY#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
1435 builder.tokenrust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]token().(KEYrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#KEY#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), key);
1436 builder.tokenrust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]token().(COLONrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#COLON#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), ":");
1437 builder.tokenrust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]token().(WHITESPACErust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#WHITESPACE#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), " ");
1438 for (i, line) in value.splitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]split().('\n').enumeraterust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#enumerate().() {
1439 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 {
1440 builder.tokenrust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]token().(INDENTrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#INDENT#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), " ");
1441 }
1442 builder.tokenrust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]token().(VALUErust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#VALUE#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), line);
1443 builder.tokenrust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]token().(NEWLINErust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#NEWLINE#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), "\n");
1444 }
1445 builder.finish_noderust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]finish_node().();
1446 }
1447 builder.finish_noderust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]finish_node().();
1448 Selfrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph][`FromIterator<(&'a str, &'a str)>`](SyntaxNoderust-analyzer cargo deb822-lossless 0.5.18 lossless/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().()))
1449 }
1450 }
1451
1452 /// Detected indentation pattern for multi-line field values
1453 #[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:)]
1454 pub enum IndentPatternrust-analyzer cargo deb822-lossless 0.5.18 lossless/IndentPattern# {
1455 /// All fields use a fixed number of spaces for indentation
1456 Fixedrust-analyzer cargo deb822-lossless 0.5.18 lossless/IndentPattern#Fixed#(usize),
1457 /// Each field's indentation matches its field name length + 2 (for ": ")
1458 FieldNameLengthrust-analyzer cargo deb822-lossless 0.5.18 lossless/IndentPattern#FieldNameLength#,
1459 }
1460
1461 impl IndentPatternrust-analyzer cargo deb822-lossless 0.5.18 lossless/IndentPattern# {
1462 /// Convert the pattern to a concrete indentation string for a given field name
1463 fn to_stringrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[IndentPattern]to_string().(&self, field_name: &str) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# {
1464 match self {
1465 IndentPatternrust-analyzer cargo deb822-lossless 0.5.18 lossless/IndentPattern#::Fixedrust-analyzer cargo deb822-lossless 0.5.18 lossless/IndentPattern#Fixed#(spaces) => " ".repeatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]repeat().(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().spaces),
1466 IndentPatternrust-analyzer cargo deb822-lossless 0.5.18 lossless/IndentPattern#::FieldNameLengthrust-analyzer cargo deb822-lossless 0.5.18 lossless/IndentPattern#FieldNameLength# => " ".repeatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]repeat().(field_name.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]len().() 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().2),
1467 }
1468 }
1469 }
1470
1471 impl Paragraphrust-analyzer cargo deb822-lossless 0.5.18 lossless/Paragraph# {
1472 /// Create a new empty paragraph.
1473 pub fn newrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]new().() -> Paragraphrust-analyzer cargo deb822-lossless 0.5.18 lossless/Paragraph# {
1474 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().();
1475
1476 builder.start_noderust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]start_node().(PARAGRAPHrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#PARAGRAPH#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
1477 builder.finish_noderust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]finish_node().();
1478 Paragraphrust-analyzer cargo deb822-lossless 0.5.18 lossless/Paragraph#(SyntaxNoderust-analyzer cargo deb822-lossless 0.5.18 lossless/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().()))
1479 }
1480
1481 /// Capture an independent snapshot of this paragraph.
1482 ///
1483 /// See [`Deb822::snapshot`] for details.
1484 pub fn snapshotrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]snapshot().(&self) -> Selfrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph] {
1485 Paragraphrust-analyzer cargo deb822-lossless 0.5.18 lossless/Paragraph#(SyntaxNoderust-analyzer cargo deb822-lossless 0.5.18 lossless/SyntaxNode#::new_root_mutrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]new_root_mut().(self.0rust-analyzer cargo deb822-lossless 0.5.18 lossless/Paragraph#0..greenrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]green().().into_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/impl#[`Cow<'_, B>`]into_owned().()))
1486 }
1487
1488 /// O(1) check: returns true iff `self` and `snapshot` reference the same
1489 /// syntax-tree state. See [`Deb822::tree_eq`].
1490 pub fn tree_eqrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]tree_eq().(&self, other: &Selfrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]) -> bool {
1491 green_eqrust-analyzer cargo deb822-lossless 0.5.18 lossless/green_eq().(&self.0rust-analyzer cargo deb822-lossless 0.5.18 lossless/Paragraph#0., &other.0rust-analyzer cargo deb822-lossless 0.5.18 lossless/Paragraph#0.)
1492 }
1493
1494 /// Returns the text range covered by this paragraph.
1495 pub fn text_rangerust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]text_range().(&self) -> rowanrust-analyzer cargo rowan 0.16.1 crate/::TextRangerust-analyzer cargo text-size 1.1.1 range/TextRange# {
1496 self.0rust-analyzer cargo deb822-lossless 0.5.18 lossless/Paragraph#0..text_rangerust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]text_range().()
1497 }
1498
1499 /// Returns entries that intersect with the given text range.
1500 ///
1501 /// An entry is included if its text range overlaps with the provided range.
1502 ///
1503 /// # Arguments
1504 ///
1505 /// * `range` - The text range to query
1506 ///
1507 /// # Returns
1508 ///
1509 /// An iterator over entries that intersect with the range
1510 ///
1511 /// # Examples
1512 ///
1513 /// ```
1514 /// use deb822_lossless::{Deb822, TextRange};
1515 ///
1516 /// let input = "Package: foo\nVersion: 1.0\nArchitecture: amd64\n";
1517 /// let deb822 = Deb822::parse(input).tree();
1518 /// let para = deb822.paragraphs().next().unwrap();
1519 ///
1520 /// // Query entries in a specific range
1521 /// let range = TextRange::new(0.into(), 15.into());
1522 /// let entries: Vec<_> = para.entries_in_range(range).collect();
1523 /// assert!(entries.len() >= 1);
1524 /// ```
1525 pub fn entries_in_rangerust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]entries_in_range().(&self, range: rowanrust-analyzer cargo rowan 0.16.1 crate/::TextRangerust-analyzer cargo text-size 1.1.1 range/TextRange#) -> 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# = Entryrust-analyzer cargo deb822-lossless 0.5.18 lossless/Entry#> + '_ {
1526 self.entriesrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]entries().().filterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#filter().(move |e| {
1527 let entry_range = e.text_rangerust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]text_range().();
1528 // Check if ranges overlap
1529 entry_range.startrust-analyzer cargo text-size 1.1.1 range/impl#[TextRange]start().() 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().range.endrust-analyzer cargo text-size 1.1.1 range/impl#[TextRange]end().() && entry_range.endrust-analyzer cargo text-size 1.1.1 range/impl#[TextRange]end().() 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().range.startrust-analyzer cargo text-size 1.1.1 range/impl#[TextRange]start().()
1530 })
1531 }
1532
1533 /// Find the entry that contains the given text offset.
1534 ///
1535 /// # Arguments
1536 ///
1537 /// * `offset` - The text offset to query
1538 ///
1539 /// # Returns
1540 ///
1541 /// The entry containing the offset, or None if no entry contains it
1542 ///
1543 /// # Examples
1544 ///
1545 /// ```
1546 /// use deb822_lossless::{Deb822, TextSize};
1547 ///
1548 /// let input = "Package: foo\nVersion: 1.0\n";
1549 /// let deb822 = Deb822::parse(input).tree();
1550 /// let para = deb822.paragraphs().next().unwrap();
1551 ///
1552 /// // Find entry at offset 5 (within "Package: foo")
1553 /// let entry = para.entry_at_position(TextSize::from(5));
1554 /// assert!(entry.is_some());
1555 /// ```
1556 pub fn entry_at_positionrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]entry_at_position().(&self, offset: rowanrust-analyzer cargo rowan 0.16.1 crate/::TextSizerust-analyzer cargo text-size 1.1.1 size/TextSize#) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Entryrust-analyzer cargo deb822-lossless 0.5.18 lossless/Entry#> {
1557 self.entriesrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]entries().().findrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#find().(|e| {
1558 let range = e.text_rangerust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]text_range().();
1559 range.containsrust-analyzer cargo text-size 1.1.1 range/impl#[TextRange]contains().(offset)
1560 })
1561 }
1562
1563 /// Reformat this paragraph
1564 ///
1565 /// # Arguments
1566 /// * `indentation` - The indentation to use
1567 /// * `immediate_empty_line` - Whether multi-line values should always start with an empty line
1568 /// * `max_line_length_one_liner` - If set, then this is the max length of the value if it is
1569 /// crammed into a "one-liner" value
1570 /// * `sort_entries` - If set, then this function will sort the entries according to the given
1571 /// function
1572 /// * `format_value` - If set, then this function will format the value according to the given
1573 /// function
1574 #[must_use]
1575 pub fn wrap_and_sortrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]wrap_and_sort().(
1576 &self,
1577 indentation: Indentationrust-analyzer cargo deb822-lossless 0.5.18 Indentation#,
1578 immediate_empty_line: bool,
1579 max_line_length_one_liner: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<usize>,
1580 sort_entries: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&dyn Fnrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/function/Fn#(&Entryrust-analyzer cargo deb822-lossless 0.5.18 lossless/Entry#, &Entryrust-analyzer cargo deb822-lossless 0.5.18 lossless/Entry#) -> 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#>,
1581 format_value: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&dyn Fnrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/function/Fn#(&str, &str) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>,
1582 ) -> Paragraphrust-analyzer cargo deb822-lossless 0.5.18 lossless/Paragraph# {
1583 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().();
1584
1585 let mut current = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![];
1586 let mut entries = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![];
1587
1588 builder.start_noderust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]start_node().(PARAGRAPHrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#PARAGRAPH#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
1589 for c in self.0rust-analyzer cargo deb822-lossless 0.5.18 lossless/Paragraph#0..children_with_tokensrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]children_with_tokens().() {
1590 match c.kindrust-analyzer cargo rowan 0.16.1 api/impl#[`NodeOrToken<SyntaxNode<L>, SyntaxToken<L>>`]kind().() {
1591 ENTRYrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#ENTRY# => {
1592 entries.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().((current, Entryrust-analyzer cargo deb822-lossless 0.5.18 lossless/Entry#::castrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]cast().(c.as_noderust-analyzer cargo rowan 0.16.1 utility_types/impl#[`NodeOrToken<N, T>`]as_node().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().clonerust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`][Clone]clone().()).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().()));
1593 current = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![];
1594 }
1595 ERRORrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#ERROR# | COMMENTrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#COMMENT# => {
1596 current.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(c);
1597 }
1598 _ => {}
1599 }
1600 }
1601
1602 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(sort_entry) = sort_entries {
1603 entries.sort_byrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]sort_by().(|a, b| {
1604 let a_key = &a.1;
1605 let b_key = &b.1;
1606 sort_entry(a_key, b_key)
1607 });
1608 }
1609
1610 for (pre, entry) in entries.into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().() {
1611 for c in pre.into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().() {
1612 builder.tokenrust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]token().(c.kindrust-analyzer cargo rowan 0.16.1 api/impl#[`NodeOrToken<SyntaxNode<L>, SyntaxToken<L>>`]kind().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), c.as_tokenrust-analyzer cargo rowan 0.16.1 utility_types/impl#[`NodeOrToken<N, T>`]as_token().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().textrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxToken<L>`]text().());
1613 }
1614
1615 injectrust-analyzer cargo deb822-lossless 0.5.18 lossless/inject().(
1616 &mut builder,
1617 entry
1618 .wrap_and_sortrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]wrap_and_sort().(
1619 indentation,
1620 immediate_empty_line,
1621 max_line_length_one_liner,
1622 format_value,
1623 )
1624 .0rust-analyzer cargo deb822-lossless 0.5.18 lossless/Entry#0.,
1625 );
1626 }
1627
1628 for c in current {
1629 builder.tokenrust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]token().(c.kindrust-analyzer cargo rowan 0.16.1 api/impl#[`NodeOrToken<SyntaxNode<L>, SyntaxToken<L>>`]kind().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), c.as_tokenrust-analyzer cargo rowan 0.16.1 utility_types/impl#[`NodeOrToken<N, T>`]as_token().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().textrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxToken<L>`]text().());
1630 }
1631
1632 builder.finish_noderust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]finish_node().();
1633 Selfrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph](SyntaxNoderust-analyzer cargo deb822-lossless 0.5.18 lossless/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().()))
1634 }
1635
1636 /// Normalize the spacing around field separators (colons) for all entries in place.
1637 ///
1638 /// This ensures that there is exactly one space after the colon and before the value
1639 /// for each field in the paragraph. This is a lossless operation that preserves the
1640 /// field names, values, and comments, but normalizes the whitespace formatting.
1641 ///
1642 /// # Examples
1643 ///
1644 /// ```
1645 /// use deb822_lossless::Deb822;
1646 /// use std::str::FromStr;
1647 ///
1648 /// let input = "Field1: value1\nField2:value2\n";
1649 /// let mut deb822 = Deb822::from_str(input).unwrap();
1650 /// let mut para = deb822.paragraphs().next().unwrap();
1651 ///
1652 /// para.normalize_field_spacing();
1653 /// assert_eq!(para.to_string(), "Field1: value1\nField2: value2\n");
1654 /// ```
1655 pub fn normalize_field_spacingrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]normalize_field_spacing().(&mut self) -> bool {
1656 let mut any_changed = false;
1657
1658 // Collect entries to avoid borrowing issues
1659 let mut entries: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_> = self.entriesrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]entries().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().();
1660
1661 // Normalize each entry
1662 for entry in &mut entries {
1663 if entry.normalize_field_spacingrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]normalize_field_spacing().() {
1664 any_changed = true;
1665 }
1666 }
1667
1668 any_changed
1669 }
1670
1671 /// Returns the value of the given key in the paragraph.
1672 ///
1673 /// Field names are compared case-insensitively.
1674 pub fn getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().(&self, key: &str) -> 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#> {
1675 self.entriesrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]entries().()
1676 .findrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#find().(|e| {
1677 e.keyrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]key().()
1678 .as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().()
1679 .is_some_andrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some_and().(|k| k.eq_ignore_ascii_caserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]eq_ignore_ascii_case().(key))
1680 })
1681 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|e| e.valuerust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]value().())
1682 }
1683
1684 /// Returns the value of the given key, including any comment lines embedded
1685 /// within multi-line values.
1686 ///
1687 /// This is like [`get()`](Self::get) but also includes `#`-prefixed comment lines
1688 /// that appear between continuation lines.
1689 ///
1690 /// Field names are compared case-insensitively.
1691 pub fn get_with_commentsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get_with_comments().(&self, key: &str) -> 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#> {
1692 self.entriesrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]entries().()
1693 .findrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#find().(|e| {
1694 e.keyrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]key().()
1695 .as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().()
1696 .is_some_andrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some_and().(|k| k.eq_ignore_ascii_caserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]eq_ignore_ascii_case().(key))
1697 })
1698 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|e| e.value_with_commentsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]value_with_comments().())
1699 }
1700
1701 /// Returns the entry for the given key in the paragraph.
1702 ///
1703 /// Field names are compared case-insensitively.
1704 pub fn get_entryrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get_entry().(&self, key: &str) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Entryrust-analyzer cargo deb822-lossless 0.5.18 lossless/Entry#> {
1705 self.entriesrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]entries().().findrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#find().(|e| {
1706 e.keyrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]key().()
1707 .as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().()
1708 .is_some_andrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some_and().(|k| k.eq_ignore_ascii_caserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]eq_ignore_ascii_case().(key))
1709 })
1710 }
1711
1712 /// Returns the value of the given key with a specific indentation pattern applied.
1713 ///
1714 /// This returns the field value reformatted as if it were written with the specified
1715 /// indentation pattern. For single-line values, this is the same as `get()`.
1716 /// For multi-line values, the continuation lines are prefixed with indentation
1717 /// calculated from the indent pattern.
1718 ///
1719 /// Field names are compared case-insensitively.
1720 ///
1721 /// # Arguments
1722 /// * `key` - The field name to retrieve
1723 /// * `indent_pattern` - The indentation pattern to apply
1724 ///
1725 /// # Example
1726 /// ```
1727 /// use deb822_lossless::{Deb822, IndentPattern};
1728 /// use std::str::FromStr;
1729 ///
1730 /// let input = "Field: First\n Second\n Third\n";
1731 /// let deb = Deb822::from_str(input).unwrap();
1732 /// let para = deb.paragraphs().next().unwrap();
1733 ///
1734 /// // Get with fixed 2-space indentation - strips 2 spaces from each line
1735 /// let value = para.get_with_indent("Field", &IndentPattern::Fixed(2)).unwrap();
1736 /// assert_eq!(value, "First\n Second\n Third");
1737 /// ```
1738 pub fn get_with_indentrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get_with_indent().(&self, key: &str, indent_pattern: &IndentPatternrust-analyzer cargo deb822-lossless 0.5.18 lossless/IndentPattern#) -> 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#> {
1739 use craterust-analyzer cargo deb822-lossless 0.5.18 crate/::lexrust-analyzer cargo deb822-lossless 0.5.18 lex/::SyntaxKindrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#::{INDENTrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#INDENT#, VALUErust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#VALUE#};
1740
1741 self.entriesrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]entries().()
1742 .findrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#find().(|e| {
1743 e.keyrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]key().()
1744 .as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().()
1745 .is_some_andrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some_and().(|k| k.eq_ignore_ascii_caserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]eq_ignore_ascii_case().(key))
1746 })
1747 .and_thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]and_then().(|e| {
1748 let field_key = e.keyrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]key().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Try]branch().;
1749 let expected_indent = indent_pattern.to_stringrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[IndentPattern]to_string().(&field_key);
1750 let expected_len = expected_indent.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]len().();
1751
1752 let mut result = Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]new().();
1753 let mut first = true;
1754 let mut last_indent: 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#> = Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#;
1755
1756 for token in e.0rust-analyzer cargo deb822-lossless 0.5.18 lossless/Entry#0..children_with_tokensrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]children_with_tokens().().filter_maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#filter_map().(|it| it.into_tokenrust-analyzer cargo rowan 0.16.1 utility_types/impl#[`NodeOrToken<N, T>`]into_token().()) {
1757 match token.kindrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxToken<L>`]kind().() {
1758 INDENTrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#INDENT# => {
1759 last_indent = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(token.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().());
1760 }
1761 VALUErust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#VALUE# => {
1762 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().first {
1763 result.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push().('\n');
1764 // Add any indentation beyond the expected amount
1765 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(ref indent_text) = last_indent {
1766 if indent_text.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]len().() 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().expected_len {
1767 result.push_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push_str().(&indent_text[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().expected_len..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().);
1768 }
1769 }
1770 }
1771 result.push_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push_str().(token.textrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxToken<L>`]text().());
1772 first = false;
1773 last_indent = Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#;
1774 }
1775 _ => {}
1776 }
1777 }
1778
1779 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(result)
1780 })
1781 }
1782
1783 /// Get a multi-line field value with single-space indentation stripped.
1784 ///
1785 /// This is a convenience wrapper around `get_with_indent()` that uses
1786 /// `IndentPattern::Fixed(1)`, which is the standard indentation for
1787 /// multi-line fields in Debian control files.
1788 ///
1789 /// # Arguments
1790 ///
1791 /// * `key` - The field name (case-insensitive)
1792 ///
1793 /// # Returns
1794 ///
1795 /// The field value with single-space indentation stripped from continuation lines,
1796 /// or `None` if the field doesn't exist.
1797 ///
1798 /// # Example
1799 ///
1800 /// ```
1801 /// use deb822_lossless::Deb822;
1802 ///
1803 /// let text = "Description: Short description\n Additional line\n";
1804 /// let deb822 = Deb822::parse(text).tree();
1805 /// let para = deb822.paragraphs().next().unwrap();
1806 /// let value = para.get_multiline("Description").unwrap();
1807 /// assert_eq!(value, "Short description\nAdditional line");
1808 /// ```
1809 pub fn get_multilinerust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get_multiline().(&self, key: &str) -> 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#> {
1810 self.get_with_indentrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get_with_indent().(key, &IndentPatternrust-analyzer cargo deb822-lossless 0.5.18 lossless/IndentPattern#::Fixedrust-analyzer cargo deb822-lossless 0.5.18 lossless/IndentPattern#Fixed#(1))
1811 }
1812
1813 /// Set a multi-line field value with single-space indentation.
1814 ///
1815 /// This is a convenience wrapper around `try_set_with_forced_indent()` that uses
1816 /// `IndentPattern::Fixed(1)`, which is the standard indentation for
1817 /// multi-line fields in Debian control files.
1818 ///
1819 /// # Arguments
1820 ///
1821 /// * `key` - The field name
1822 /// * `value` - The field value (will be formatted with single-space indentation)
1823 /// * `field_order` - Optional field ordering specification
1824 ///
1825 /// # Returns
1826 ///
1827 /// `Ok(())` if successful, or an `Error` if the value is invalid.
1828 ///
1829 /// # Example
1830 ///
1831 /// ```
1832 /// use deb822_lossless::Paragraph;
1833 ///
1834 /// let mut para = Paragraph::new();
1835 /// para.set_multiline("Description", "Short description\nAdditional line", None).unwrap();
1836 /// assert_eq!(para.get_multiline("Description").unwrap(), "Short description\nAdditional line");
1837 /// ```
1838 pub fn set_multilinerust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]set_multiline().(
1839 &mut self,
1840 key: &str,
1841 value: &str,
1842 field_order: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&[&str]>,
1843 ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Errorrust-analyzer cargo deb822-lossless 0.5.18 lossless/Error#> {
1844 self.try_set_with_forced_indentrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]try_set_with_forced_indent().(key, value, &IndentPatternrust-analyzer cargo deb822-lossless 0.5.18 lossless/IndentPattern#::Fixedrust-analyzer cargo deb822-lossless 0.5.18 lossless/IndentPattern#Fixed#(1), field_order)
1845 }
1846
1847 /// Returns whether the paragraph contains the given key.
1848 pub fn contains_keyrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]contains_key().(&self, key: &str) -> bool {
1849 self.getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().(key).is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().()
1850 }
1851
1852 /// Returns an iterator over all entries in the paragraph.
1853 pub fn entriesrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]entries().(&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# = Entryrust-analyzer cargo deb822-lossless 0.5.18 lossless/Entry#> + '_ {
1854 self.0rust-analyzer cargo deb822-lossless 0.5.18 lossless/Paragraph#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().(Entryrust-analyzer cargo deb822-lossless 0.5.18 lossless/Entry#::castrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]cast().)
1855 }
1856
1857 /// Returns an iterator over all items in the paragraph.
1858 pub fn itemsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]items().(&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# = (Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#)> + '_ {
1859 self.entriesrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]entries().()
1860 .filter_maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#filter_map().(|e| e.keyrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]key().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|k| (k, e.valuerust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]value().())))
1861 }
1862
1863 /// Returns an iterator over all values for the given key in the paragraph.
1864 ///
1865 /// Field names are compared case-insensitively.
1866 pub fn get_allrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get_all().<'a>(&'a self, key: &'a str) -> 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# = Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> + 'a {
1867 self.itemsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]items().().filter_maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#filter_map().(move |(k, v)| {
1868 if k.eq_ignore_ascii_caserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]eq_ignore_ascii_case().(key) {
1869 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(v)
1870 } else {
1871 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#
1872 }
1873 })
1874 }
1875
1876 /// Returns an iterator over all keys in the paragraph.
1877 pub fn keysrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]keys().(&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# = Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> + '_ {
1878 self.entriesrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]entries().().filter_maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#filter_map().(|e| e.keyrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]key().())
1879 }
1880
1881 /// Remove the given field from the paragraph.
1882 ///
1883 /// Field names are compared case-insensitively.
1884 pub fn removerust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]remove().(&mut self, key: &str) {
1885 for mut entry in self.entriesrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]entries().() {
1886 if entry
1887 .keyrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]key().()
1888 .as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().()
1889 .is_some_andrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some_and().(|k| k.eq_ignore_ascii_caserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]eq_ignore_ascii_case().(key))
1890 {
1891 entry.detachrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]detach().();
1892 }
1893 }
1894 }
1895
1896 /// Insert a new field
1897 pub fn insertrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]insert().(&mut self, key: &str, value: &str) {
1898 let entry = Entryrust-analyzer cargo deb822-lossless 0.5.18 lossless/Entry#::newrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]new().(key, value);
1899 let count = self.0rust-analyzer cargo deb822-lossless 0.5.18 lossless/Paragraph#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().();
1900 self.0rust-analyzer cargo deb822-lossless 0.5.18 lossless/Paragraph#0..splice_childrenrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]splice_children().(count..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#count, vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![entry.0rust-analyzer cargo deb822-lossless 0.5.18 lossless/Entry#0..intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()]);
1901 }
1902
1903 /// Insert a comment line before this paragraph.
1904 ///
1905 /// The comment should not include the leading '#' character or newline,
1906 /// these will be added automatically.
1907 ///
1908 /// # Examples
1909 ///
1910 /// ```
1911 /// use deb822_lossless::Deb822;
1912 /// let mut d: Deb822 = vec![
1913 /// vec![("Foo", "Bar")].into_iter().collect(),
1914 /// ]
1915 /// .into_iter()
1916 /// .collect();
1917 /// let mut para = d.paragraphs().next().unwrap();
1918 /// para.insert_comment_before("This is a comment");
1919 /// assert_eq!(d.to_string(), "# This is a comment\nFoo: Bar\n");
1920 /// ```
1921 pub fn insert_comment_beforerust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]insert_comment_before().(&mut self, comment: &str) {
1922 use rowanrust-analyzer cargo rowan 0.16.1 crate/::GreenNodeBuilderrust-analyzer cargo rowan 0.16.1 green/builder/GreenNodeBuilder#;
1923
1924 // Create an EMPTY_LINE node containing the comment tokens
1925 // This matches the structure used elsewhere in the parser
1926 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().();
1927 builder.start_noderust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]start_node().(EMPTY_LINErust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#EMPTY_LINE#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
1928 builder.tokenrust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]token().(COMMENTrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#COMMENT#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), &formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("# {}", comment));
1929 builder.tokenrust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]token().(NEWLINErust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#NEWLINE#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), "\n");
1930 builder.finish_noderust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]finish_node().();
1931 let green = builder.finishrust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]finish().();
1932
1933 // Convert to syntax node and insert before this paragraph
1934 let comment_node = SyntaxNoderust-analyzer cargo deb822-lossless 0.5.18 lossless/SyntaxNode#::new_root_mutrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]new_root_mut().(green);
1935
1936 let index = self.0rust-analyzer cargo deb822-lossless 0.5.18 lossless/Paragraph#0..indexrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]index().();
1937 let parent = self.0rust-analyzer cargo deb822-lossless 0.5.18 lossless/Paragraph#0..parentrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]parent().().expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]expect().("Paragraph must have a parent");
1938 parent.splice_childrenrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]splice_children().(index..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#index, vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![comment_node.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()]);
1939 }
1940
1941 /// Detect the indentation pattern used in this paragraph.
1942 ///
1943 /// This method analyzes existing multi-line fields to determine if they use:
1944 /// 1. A fixed indentation (all fields use the same number of spaces)
1945 /// 2. Field-name-length-based indentation (indent matches field name + ": ")
1946 ///
1947 /// If no pattern can be detected, defaults to field name length + 2.
1948 fn detect_indent_patternrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]detect_indent_pattern().(&self) -> IndentPatternrust-analyzer cargo deb822-lossless 0.5.18 lossless/IndentPattern# {
1949 // Collect indentation data from existing multi-line fields
1950 let indent_data: 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#, usize)> = self
1951 .entriesrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]entries().()
1952 .filter_maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#filter_map().(|entry| {
1953 let field_key = entry.keyrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]key().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Try]branch().;
1954 let indent = entry.get_indentrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]get_indent().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Try]branch().;
1955 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((field_key, indent.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]len().()))
1956 })
1957 .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().();
1958
1959 if indent_data.is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().() {
1960 // No existing multi-line fields, default to field name length
1961 return IndentPatternrust-analyzer cargo deb822-lossless 0.5.18 lossless/IndentPattern#::FieldNameLengthrust-analyzer cargo deb822-lossless 0.5.18 lossless/IndentPattern#FieldNameLength#;
1962 }
1963
1964 // Check if all fields use the same fixed indentation
1965 let first_indent_len = indent_data[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()..1;
1966 let all_same = indent_data.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().allrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]all().(|(_, len)| *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().len 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().first_indent_len);
1967
1968 if all_same {
1969 // All fields use the same indentation - use that
1970 return IndentPatternrust-analyzer cargo deb822-lossless 0.5.18 lossless/IndentPattern#::Fixedrust-analyzer cargo deb822-lossless 0.5.18 lossless/IndentPattern#Fixed#(first_indent_len);
1971 }
1972
1973 // Check if fields use field-name-length-based indentation
1974 let all_match_field_length = indent_data
1975 .iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().()
1976 .allrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]all().(|(field_key, indent_len)| *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().indent_len 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().field_key.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]len().() 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().2);
1977
1978 if all_match_field_length {
1979 // Fields use field-name-length-based indentation
1980 return IndentPatternrust-analyzer cargo deb822-lossless 0.5.18 lossless/IndentPattern#::FieldNameLengthrust-analyzer cargo deb822-lossless 0.5.18 lossless/IndentPattern#FieldNameLength#;
1981 }
1982
1983 // Can't detect a clear pattern, default to field name length + 2
1984 IndentPatternrust-analyzer cargo deb822-lossless 0.5.18 lossless/IndentPattern#::FieldNameLengthrust-analyzer cargo deb822-lossless 0.5.18 lossless/IndentPattern#FieldNameLength#
1985 }
1986
1987 /// Try to set a field in the paragraph, inserting at the appropriate location if new.
1988 ///
1989 /// # Errors
1990 /// Returns an error if the value contains empty continuation lines (lines with only whitespace)
1991 pub fn try_setrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]try_set().(&mut self, key: &str, value: &str) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Errorrust-analyzer cargo deb822-lossless 0.5.18 lossless/Error#> {
1992 self.try_set_with_indent_patternrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]try_set_with_indent_pattern().(key, value, 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#)
1993 }
1994
1995 /// Set a field in the paragraph, inserting at the appropriate location if new
1996 ///
1997 /// # Panics
1998 /// Panics if the value contains empty continuation lines (lines with only whitespace)
1999 pub fn setrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]set().(&mut self, key: &str, value: &str) {
2000 self.try_setrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]try_set().(key, value)
2001 .expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("Invalid value: empty continuation line")
2002 }
2003
2004 /// Set a field using a specific field ordering
2005 pub fn set_with_field_orderrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]set_with_field_order().(&mut self, key: &str, value: &str, field_order: &[&str]) {
2006 self.try_set_with_indent_patternrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]try_set_with_indent_pattern().(key, value, 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#(field_order))
2007 .expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("Invalid value: empty continuation line")
2008 }
2009
2010 /// Try to set a field with optional default indentation pattern and field ordering.
2011 ///
2012 /// This method allows setting a field while optionally specifying a default indentation pattern
2013 /// to use when the field doesn't already have multi-line indentation to preserve.
2014 /// If the field already exists and is multi-line, its existing indentation is preserved.
2015 ///
2016 /// # Arguments
2017 /// * `key` - The field name
2018 /// * `value` - The field value
2019 /// * `default_indent_pattern` - Optional default indentation pattern to use for new fields or
2020 /// fields without existing multi-line indentation. If None, will preserve existing field's
2021 /// indentation or auto-detect from other fields
2022 /// * `field_order` - Optional field ordering for positioning the field. If None, inserts at end
2023 ///
2024 /// # Errors
2025 /// Returns an error if the value contains empty continuation lines (lines with only whitespace)
2026 pub fn try_set_with_indent_patternrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]try_set_with_indent_pattern().(
2027 &mut self,
2028 key: &str,
2029 value: &str,
2030 default_indent_pattern: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&IndentPatternrust-analyzer cargo deb822-lossless 0.5.18 lossless/IndentPattern#>,
2031 field_order: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&[&str]>,
2032 ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Errorrust-analyzer cargo deb822-lossless 0.5.18 lossless/Error#> {
2033 // Check if the field already exists and extract its formatting (case-insensitive)
2034 let existing_entry = self.entriesrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]entries().().findrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#find().(|entry| {
2035 entry
2036 .keyrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]key().()
2037 .as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().()
2038 .is_some_andrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some_and().(|k| k.eq_ignore_ascii_caserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]eq_ignore_ascii_case().(key))
2039 });
2040
2041 // Determine indentation to use
2042 let indent = existing_entry
2043 .as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().()
2044 .and_thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]and_then().(|entry| entry.get_indentrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]get_indent().())
2045 .unwrap_or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or_else().(|| {
2046 // No existing indentation, use default pattern or auto-detect
2047 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(pattern) = default_indent_pattern {
2048 pattern.to_stringrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[IndentPattern]to_string().(key)
2049 } else {
2050 self.detect_indent_patternrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]detect_indent_pattern().().to_stringrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[IndentPattern]to_string().(key)
2051 }
2052 });
2053
2054 let post_colon_ws = existing_entry
2055 .as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().()
2056 .and_thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]and_then().(|entry| entry.get_post_colon_whitespacerust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]get_post_colon_whitespace().())
2057 .unwrap_or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or_else().(|| " ".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().());
2058
2059 // When replacing an existing field, preserve the original case of the field name
2060 let actual_key = existing_entry
2061 .as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().()
2062 .and_thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]and_then().(|e| e.keyrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]key().())
2063 .unwrap_or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or_else().(|| key.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().());
2064
2065 let new_entry = Entryrust-analyzer cargo deb822-lossless 0.5.18 lossless/Entry#::try_with_formattingrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]try_with_formatting().(&actual_key, value, &post_colon_ws, &indent)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
2066
2067 // Check if the field already exists and replace it (case-insensitive)
2068 for entry in self.entriesrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]entries().() {
2069 if entry
2070 .keyrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]key().()
2071 .as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().()
2072 .is_some_andrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some_and().(|k| k.eq_ignore_ascii_caserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]eq_ignore_ascii_case().(key))
2073 {
2074 self.0rust-analyzer cargo deb822-lossless 0.5.18 lossless/Paragraph#0..splice_childrenrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]splice_children().(
2075 entry.0rust-analyzer cargo deb822-lossless 0.5.18 lossless/Entry#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#entry.0rust-analyzer cargo deb822-lossless 0.5.18 lossless/Entry#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,
2076 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![new_entry.0rust-analyzer cargo deb822-lossless 0.5.18 lossless/Entry#0..intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()],
2077 );
2078 return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(());
2079 }
2080 }
2081
2082 // Insert new field
2083 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(order) = field_order {
2084 let insertion_index = self.find_insertion_indexrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]find_insertion_index().(key, order);
2085 self.0rust-analyzer cargo deb822-lossless 0.5.18 lossless/Paragraph#0.
2086 .splice_childrenrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]splice_children().(insertion_index..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#insertion_index, vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![new_entry.0rust-analyzer cargo deb822-lossless 0.5.18 lossless/Entry#0..intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()]);
2087 } else {
2088 // Insert at the end if no field order specified
2089 let insertion_index = self.0rust-analyzer cargo deb822-lossless 0.5.18 lossless/Paragraph#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().();
2090 self.0rust-analyzer cargo deb822-lossless 0.5.18 lossless/Paragraph#0.
2091 .splice_childrenrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]splice_children().(insertion_index..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#insertion_index, vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![new_entry.0rust-analyzer cargo deb822-lossless 0.5.18 lossless/Entry#0..intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()]);
2092 }
2093 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
2094 }
2095
2096 /// Set a field with optional default indentation pattern and field ordering.
2097 ///
2098 /// This method allows setting a field while optionally specifying a default indentation pattern
2099 /// to use when the field doesn't already have multi-line indentation to preserve.
2100 /// If the field already exists and is multi-line, its existing indentation is preserved.
2101 ///
2102 /// # Arguments
2103 /// * `key` - The field name
2104 /// * `value` - The field value
2105 /// * `default_indent_pattern` - Optional default indentation pattern to use for new fields or
2106 /// fields without existing multi-line indentation. If None, will preserve existing field's
2107 /// indentation or auto-detect from other fields
2108 /// * `field_order` - Optional field ordering for positioning the field. If None, inserts at end
2109 ///
2110 /// # Panics
2111 /// Panics if the value contains empty continuation lines (lines with only whitespace)
2112 pub fn set_with_indent_patternrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]set_with_indent_pattern().(
2113 &mut self,
2114 key: &str,
2115 value: &str,
2116 default_indent_pattern: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&IndentPatternrust-analyzer cargo deb822-lossless 0.5.18 lossless/IndentPattern#>,
2117 field_order: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&[&str]>,
2118 ) {
2119 self.try_set_with_indent_patternrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]try_set_with_indent_pattern().(key, value, default_indent_pattern, field_order)
2120 .expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("Invalid value: empty continuation line")
2121 }
2122
2123 /// Try to set a field, forcing a specific indentation pattern regardless of existing indentation.
2124 ///
2125 /// Unlike `try_set_with_indent_pattern`, this method does NOT preserve existing field indentation.
2126 /// It always applies the specified indentation pattern to the field.
2127 ///
2128 /// # Arguments
2129 /// * `key` - The field name
2130 /// * `value` - The field value
2131 /// * `indent_pattern` - The indentation pattern to use for this field
2132 /// * `field_order` - Optional field ordering for positioning the field. If None, inserts at end
2133 ///
2134 /// # Errors
2135 /// Returns an error if the value contains empty continuation lines (lines with only whitespace)
2136 pub fn try_set_with_forced_indentrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]try_set_with_forced_indent().(
2137 &mut self,
2138 key: &str,
2139 value: &str,
2140 indent_pattern: &IndentPatternrust-analyzer cargo deb822-lossless 0.5.18 lossless/IndentPattern#,
2141 field_order: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&[&str]>,
2142 ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Errorrust-analyzer cargo deb822-lossless 0.5.18 lossless/Error#> {
2143 // Check if the field already exists (case-insensitive)
2144 let existing_entry = self.entriesrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]entries().().findrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#find().(|entry| {
2145 entry
2146 .keyrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]key().()
2147 .as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().()
2148 .is_some_andrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some_and().(|k| k.eq_ignore_ascii_caserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]eq_ignore_ascii_case().(key))
2149 });
2150
2151 // Get post-colon whitespace from existing field, or default to single space
2152 let post_colon_ws = existing_entry
2153 .as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().()
2154 .and_thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]and_then().(|entry| entry.get_post_colon_whitespacerust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]get_post_colon_whitespace().())
2155 .unwrap_or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or_else().(|| " ".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().());
2156
2157 // When replacing an existing field, preserve the original case of the field name
2158 let actual_key = existing_entry
2159 .as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().()
2160 .and_thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]and_then().(|e| e.keyrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]key().())
2161 .unwrap_or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or_else().(|| key.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().());
2162
2163 // Force the indentation pattern
2164 let indent = indent_pattern.to_stringrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[IndentPattern]to_string().(&actual_key);
2165 let new_entry = Entryrust-analyzer cargo deb822-lossless 0.5.18 lossless/Entry#::try_with_formattingrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]try_with_formatting().(&actual_key, value, &post_colon_ws, &indent)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
2166
2167 // Check if the field already exists and replace it (case-insensitive)
2168 for entry in self.entriesrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]entries().() {
2169 if entry
2170 .keyrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]key().()
2171 .as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().()
2172 .is_some_andrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some_and().(|k| k.eq_ignore_ascii_caserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]eq_ignore_ascii_case().(key))
2173 {
2174 self.0rust-analyzer cargo deb822-lossless 0.5.18 lossless/Paragraph#0..splice_childrenrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]splice_children().(
2175 entry.0rust-analyzer cargo deb822-lossless 0.5.18 lossless/Entry#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#entry.0rust-analyzer cargo deb822-lossless 0.5.18 lossless/Entry#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,
2176 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![new_entry.0rust-analyzer cargo deb822-lossless 0.5.18 lossless/Entry#0..intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()],
2177 );
2178 return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(());
2179 }
2180 }
2181
2182 // Insert new field
2183 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(order) = field_order {
2184 let insertion_index = self.find_insertion_indexrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]find_insertion_index().(key, order);
2185 self.0rust-analyzer cargo deb822-lossless 0.5.18 lossless/Paragraph#0.
2186 .splice_childrenrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]splice_children().(insertion_index..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#insertion_index, vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![new_entry.0rust-analyzer cargo deb822-lossless 0.5.18 lossless/Entry#0..intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()]);
2187 } else {
2188 // Insert at the end if no field order specified
2189 let insertion_index = self.0rust-analyzer cargo deb822-lossless 0.5.18 lossless/Paragraph#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().();
2190 self.0rust-analyzer cargo deb822-lossless 0.5.18 lossless/Paragraph#0.
2191 .splice_childrenrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]splice_children().(insertion_index..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#insertion_index, vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![new_entry.0rust-analyzer cargo deb822-lossless 0.5.18 lossless/Entry#0..intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()]);
2192 }
2193 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
2194 }
2195
2196 /// Set a field, forcing a specific indentation pattern regardless of existing indentation.
2197 ///
2198 /// Unlike `set_with_indent_pattern`, this method does NOT preserve existing field indentation.
2199 /// It always applies the specified indentation pattern to the field.
2200 ///
2201 /// # Arguments
2202 /// * `key` - The field name
2203 /// * `value` - The field value
2204 /// * `indent_pattern` - The indentation pattern to use for this field
2205 /// * `field_order` - Optional field ordering for positioning the field. If None, inserts at end
2206 ///
2207 /// # Panics
2208 /// Panics if the value contains empty continuation lines (lines with only whitespace)
2209 pub fn set_with_forced_indentrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]set_with_forced_indent().(
2210 &mut self,
2211 key: &str,
2212 value: &str,
2213 indent_pattern: &IndentPatternrust-analyzer cargo deb822-lossless 0.5.18 lossless/IndentPattern#,
2214 field_order: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&[&str]>,
2215 ) {
2216 self.try_set_with_forced_indentrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]try_set_with_forced_indent().(key, value, indent_pattern, field_order)
2217 .expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("Invalid value: empty continuation line")
2218 }
2219
2220 /// Change the indentation of an existing field without modifying its value.
2221 ///
2222 /// This method finds an existing field and reapplies it with a new indentation pattern,
2223 /// preserving the field's current value.
2224 ///
2225 /// # Arguments
2226 /// * `key` - The field name to update
2227 /// * `indent_pattern` - The new indentation pattern to apply
2228 ///
2229 /// # Returns
2230 /// Returns `Ok(true)` if the field was found and updated, `Ok(false)` if the field doesn't exist,
2231 /// or `Err` if there was an error (e.g., invalid value with empty continuation lines)
2232 ///
2233 /// # Errors
2234 /// Returns an error if the field value contains empty continuation lines (lines with only whitespace)
2235 pub fn change_field_indentrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]change_field_indent().(
2236 &mut self,
2237 key: &str,
2238 indent_pattern: &IndentPatternrust-analyzer cargo deb822-lossless 0.5.18 lossless/IndentPattern#,
2239 ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<bool, Errorrust-analyzer cargo deb822-lossless 0.5.18 lossless/Error#> {
2240 // Check if the field exists (case-insensitive)
2241 let existing_entry = self.entriesrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]entries().().findrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#find().(|entry| {
2242 entry
2243 .keyrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]key().()
2244 .as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().()
2245 .is_some_andrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some_and().(|k| k.eq_ignore_ascii_caserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]eq_ignore_ascii_case().(key))
2246 });
2247
2248 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(entry) = existing_entry {
2249 let value = entry.valuerust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]value().();
2250 let actual_key = entry.keyrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]key().().unwrap_or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or_else().(|| key.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().());
2251
2252 // Get post-colon whitespace from existing field
2253 let post_colon_ws = entry
2254 .get_post_colon_whitespacerust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]get_post_colon_whitespace().()
2255 .unwrap_or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or_else().(|| " ".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().());
2256
2257 // Apply the new indentation pattern
2258 let indent = indent_pattern.to_stringrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[IndentPattern]to_string().(&actual_key);
2259 let new_entry =
2260 Entryrust-analyzer cargo deb822-lossless 0.5.18 lossless/Entry#::try_with_formattingrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]try_with_formatting().(&actual_key, &value, &post_colon_ws, &indent)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
2261
2262 // Replace the existing entry
2263 self.0rust-analyzer cargo deb822-lossless 0.5.18 lossless/Paragraph#0..splice_childrenrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]splice_children().(
2264 entry.0rust-analyzer cargo deb822-lossless 0.5.18 lossless/Entry#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#entry.0rust-analyzer cargo deb822-lossless 0.5.18 lossless/Entry#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,
2265 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![new_entry.0rust-analyzer cargo deb822-lossless 0.5.18 lossless/Entry#0..intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()],
2266 );
2267 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(true)
2268 } else {
2269 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(false)
2270 }
2271 }
2272
2273 /// Find the appropriate insertion index for a new field based on field ordering
2274 fn find_insertion_indexrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]find_insertion_index().(&self, key: &str, field_order: &[&str]) -> usize {
2275 // Find position of the new field in the canonical order (case-insensitive)
2276 let new_field_position = field_order
2277 .iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().()
2278 .positionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]position().(|&field| field.eq_ignore_ascii_caserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]eq_ignore_ascii_case().(key));
2279
2280 let mut insertion_index = self.0rust-analyzer cargo deb822-lossless 0.5.18 lossless/Paragraph#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().();
2281
2282 // Find the right position based on canonical field order
2283 for (i, child) in self.0rust-analyzer cargo deb822-lossless 0.5.18 lossless/Paragraph#0..children_with_tokensrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]children_with_tokens().().enumeraterust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#enumerate().() {
2284 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(node) = child.as_noderust-analyzer cargo rowan 0.16.1 utility_types/impl#[`NodeOrToken<N, T>`]as_node().() {
2285 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(entry) = Entryrust-analyzer cargo deb822-lossless 0.5.18 lossless/Entry#::castrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]cast().(node.clonerust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`][Clone]clone().()) {
2286 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(existing_key) = entry.keyrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]key().() {
2287 let existing_position = field_order
2288 .iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().()
2289 .positionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]position().(|&field| field.eq_ignore_ascii_caserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]eq_ignore_ascii_case().(&existing_key));
2290
2291 match (new_field_position, existing_position) {
2292 // Both fields are in the canonical order
2293 (Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(new_pos), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(existing_pos)) => {
2294 if new_pos 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().existing_pos {
2295 insertion_index = i;
2296 break;
2297 }
2298 }
2299 // New field is in canonical order, existing is not
2300 (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#) => {
2301 // Continue looking - unknown fields go after known ones
2302 }
2303 // New field is not in canonical order, existing is
2304 (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#(_)) => {
2305 // Continue until we find all known fields
2306 }
2307 // Neither field is in canonical order, maintain alphabetical
2308 (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#) => {
2309 if key rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialOrd<&B>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialOrd<&B>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialOrd<&B>`]lt().existing_key.as_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]as_str().() {
2310 insertion_index = i;
2311 break;
2312 }
2313 }
2314 }
2315 }
2316 }
2317 }
2318 }
2319
2320 // If we have a position in canonical order but haven't found where to insert yet,
2321 // we need to insert after all known fields that come before it
2322 if new_field_position.is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().() && insertion_index 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().self.0rust-analyzer cargo deb822-lossless 0.5.18 lossless/Paragraph#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().()
2323 {
2324 // Look for the position after the last known field that comes before our field
2325 let children: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_> = self.0rust-analyzer cargo deb822-lossless 0.5.18 lossless/Paragraph#0..children_with_tokensrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]children_with_tokens().().enumeraterust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#enumerate().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().();
2326 for (i, child) in children.into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().().revrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#rev().() {
2327 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(node) = child.as_noderust-analyzer cargo rowan 0.16.1 utility_types/impl#[`NodeOrToken<N, T>`]as_node().() {
2328 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(entry) = Entryrust-analyzer cargo deb822-lossless 0.5.18 lossless/Entry#::castrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]cast().(node.clonerust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`][Clone]clone().()) {
2329 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(existing_key) = entry.keyrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]key().() {
2330 if field_order
2331 .iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().()
2332 .anyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]any().(|&f| f.eq_ignore_ascii_caserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]eq_ignore_ascii_case().(&existing_key))
2333 {
2334 // Found a known field, insert after it
2335 insertion_index = i 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;
2336 break;
2337 }
2338 }
2339 }
2340 }
2341 }
2342 }
2343
2344 insertion_index
2345 }
2346
2347 /// Rename the given field in the paragraph.
2348 ///
2349 /// Field names are compared case-insensitively. The entry's existing
2350 /// formatting (post-colon whitespace, continuation-line indentation) is
2351 /// preserved — only the key token is replaced.
2352 pub fn renamerust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]rename().(&mut self, old_key: &str, new_key: &str) -> bool {
2353 for entry in self.entriesrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]entries().() {
2354 if entry
2355 .keyrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]key().()
2356 .as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().()
2357 .is_some_andrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some_and().(|k| k.eq_ignore_ascii_caserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]eq_ignore_ascii_case().(old_key))
2358 {
2359 let key_index = entry
2360 .0rust-analyzer cargo deb822-lossless 0.5.18 lossless/Entry#0.
2361 .children_with_tokensrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]children_with_tokens().()
2362 .positionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#position().(|it| it.as_tokenrust-analyzer cargo rowan 0.16.1 utility_types/impl#[`NodeOrToken<N, T>`]as_token().().is_some_andrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some_and().(|t| t.kindrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxToken<L>`]kind().() rust-analyzer cargo deb822-lossless 0.5.18 lex/impl#[SyntaxKind][`PartialEq<Self>`]eq().==rust-analyzer cargo deb822-lossless 0.5.18 lex/impl#[SyntaxKind][`PartialEq<Self>`]eq(). rust-analyzer cargo deb822-lossless 0.5.18 lex/impl#[SyntaxKind][`PartialEq<Self>`]eq().KEYrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#KEY#));
2363 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(key_index) = key_index {
2364 let new_token =
2365 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#(rowanrust-analyzer cargo rowan 0.16.1 crate/::GreenTokenrust-analyzer cargo rowan 0.16.1 green/token/GreenToken#::newrust-analyzer cargo rowan 0.16.1 green/token/impl#[GreenToken]new().(KEYrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#KEY#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), new_key));
2366 let new_green = entry
2367 .0rust-analyzer cargo deb822-lossless 0.5.18 lossless/Entry#0.
2368 .greenrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]green().()
2369 .splice_childrenrust-analyzer cargo rowan 0.16.1 green/node/impl#[GreenNodeData]splice_children().(key_index..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#key_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, vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![new_token]);
2370 let parent = entry.0rust-analyzer cargo deb822-lossless 0.5.18 lossless/Entry#0..parentrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]parent().().expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]expect().("Entry must have a parent");
2371 parent.splice_childrenrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]splice_children().(
2372 entry.0rust-analyzer cargo deb822-lossless 0.5.18 lossless/Entry#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#entry.0rust-analyzer cargo deb822-lossless 0.5.18 lossless/Entry#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,
2373 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![SyntaxNoderust-analyzer cargo deb822-lossless 0.5.18 lossless/SyntaxNode#::new_root_mutrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]new_root_mut().(new_green).intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()],
2374 );
2375 return true;
2376 }
2377 }
2378 }
2379 false
2380 }
2381 }
2382
2383 impl Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default# for Paragraphrust-analyzer cargo deb822-lossless 0.5.18 lossless/Paragraph# {
2384 fn defaultrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph][Default]default().() -> Selfrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph][Default] {
2385 Selfrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph][Default]::newrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]new().()
2386 }
2387 }
2388
2389 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 Paragraphrust-analyzer cargo deb822-lossless 0.5.18 lossless/Paragraph# {
2390 type Errrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph][FromStr]Err# = ParseErrorrust-analyzer cargo deb822-lossless 0.5.18 lossless/ParseError#;
2391
2392 fn from_strrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph][FromStr]from_str().(text: &str) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph][FromStr], Selfrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph][FromStr]::Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/traits/FromStr#Err#> {
2393 let deb822 = Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#::from_strrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822][FromStr]from_str().(text)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
2394
2395 let mut paragraphs = deb822.paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraphs().();
2396
2397 paragraphs
2398 .nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/filter_map/impl#[`FilterMap<I, F>`][Iterator]next().()
2399 .ok_or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]ok_or_else().(|| ParseErrorrust-analyzer cargo deb822-lossless 0.5.18 lossless/ParseError#(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!!["no paragraphs".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()]))
2400 }
2401 }
2402
2403 #[cfg(feature = "python-debian")]
2404 impl<'py> pyo3rust-analyzer cargo pyo3 0.28.3 crate/::IntoPyObjectrust-analyzer cargo pyo3 0.28.3 conversion/IntoPyObject#<'py> for Paragraphrust-analyzer cargo deb822-lossless 0.5.18 lossless/Paragraph# {
2405 type Targetrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph][`IntoPyObject<'py>`]Target# = pyo3rust-analyzer cargo pyo3 0.28.3 crate/::PyAnyrust-analyzer cargo pyo3 0.28.3 types/any/PyAny#;
2406 type Outputrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph][`IntoPyObject<'py>`]Output# = pyo3rust-analyzer cargo pyo3 0.28.3 crate/::Boundrust-analyzer cargo pyo3 0.28.3 instance/Bound#<'py, Selfrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph][`IntoPyObject<'py>`]::Targetrust-analyzer cargo pyo3 0.28.3 conversion/IntoPyObject#Target#>;
2407 type Errorrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph][`IntoPyObject<'py>`]Error# = pyo3rust-analyzer cargo pyo3 0.28.3 crate/::PyErrrust-analyzer cargo pyo3 0.28.3 err/PyErr#;
2408
2409 fn into_pyobjectrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph][`IntoPyObject<'py>`]into_pyobject().(self, py: pyo3rust-analyzer cargo pyo3 0.28.3 crate/::Pythonrust-analyzer cargo pyo3 0.28.3 marker/Python#<'py>) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph][`IntoPyObject<'py>`]::Outputrust-analyzer cargo pyo3 0.28.3 conversion/IntoPyObject#Output#, Selfrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph][`IntoPyObject<'py>`]::Errorrust-analyzer cargo pyo3 0.28.3 conversion/IntoPyObject#Error#> {
2410 use pyo3rust-analyzer cargo pyo3 0.28.3 crate/::preluderust-analyzer cargo pyo3 0.28.3 prelude/::*;
2411 let d = pyo3rust-analyzer cargo pyo3 0.28.3 crate/::typesrust-analyzer cargo pyo3 0.28.3 types/::PyDictrust-analyzer cargo pyo3 0.28.3 types/dict/PyDict#::newrust-analyzer cargo pyo3 0.28.3 types/dict/impl#[PyDict]new().(py);
2412 for (k, v) in self.itemsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]items().() {
2413 d.set_itemrust-analyzer cargo pyo3 0.28.3 types/dict/impl#[`Bound<'py, PyDict>`][`PyDictMethods<'py>`]set_item().(k, v)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
2414 }
2415 let m = py.importrust-analyzer cargo pyo3 0.28.3 marker/impl#[`Python<'py>`]import().("debian.deb822")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
2416 let cls = m.getattrrust-analyzer cargo pyo3 0.28.3 types/any/impl#[`Bound<'py, PyAny>`][`PyAnyMethods<'py>`]getattr().("Deb822")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
2417 cls.call1rust-analyzer cargo pyo3 0.28.3 types/any/impl#[`Bound<'py, PyAny>`][`PyAnyMethods<'py>`]call1().((d,))
2418 }
2419 }
2420
2421 #[cfg(feature = "python-debian")]
2422 impl<'py> pyo3rust-analyzer cargo pyo3 0.28.3 crate/::IntoPyObjectrust-analyzer cargo pyo3 0.28.3 conversion/IntoPyObject#<'py> for &Paragraphrust-analyzer cargo deb822-lossless 0.5.18 lossless/Paragraph# {
2423 type Targetrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`&Paragraph`][`IntoPyObject<'py>`]Target# = pyo3rust-analyzer cargo pyo3 0.28.3 crate/::PyAnyrust-analyzer cargo pyo3 0.28.3 types/any/PyAny#;
2424 type Outputrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`&Paragraph`][`IntoPyObject<'py>`]Output# = pyo3rust-analyzer cargo pyo3 0.28.3 crate/::Boundrust-analyzer cargo pyo3 0.28.3 instance/Bound#<'py, Selfrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`&Paragraph`][`IntoPyObject<'py>`]::Targetrust-analyzer cargo pyo3 0.28.3 conversion/IntoPyObject#Target#>;
2425 type Errorrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`&Paragraph`][`IntoPyObject<'py>`]Error# = pyo3rust-analyzer cargo pyo3 0.28.3 crate/::PyErrrust-analyzer cargo pyo3 0.28.3 err/PyErr#;
2426
2427 fn into_pyobjectrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`&Paragraph`][`IntoPyObject<'py>`]into_pyobject().(self, py: pyo3rust-analyzer cargo pyo3 0.28.3 crate/::Pythonrust-analyzer cargo pyo3 0.28.3 marker/Python#<'py>) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`&Paragraph`][`IntoPyObject<'py>`]::Outputrust-analyzer cargo pyo3 0.28.3 conversion/IntoPyObject#Output#, Selfrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[`&Paragraph`][`IntoPyObject<'py>`]::Errorrust-analyzer cargo pyo3 0.28.3 conversion/IntoPyObject#Error#> {
2428 use pyo3rust-analyzer cargo pyo3 0.28.3 crate/::preluderust-analyzer cargo pyo3 0.28.3 prelude/::*;
2429 let d = pyo3rust-analyzer cargo pyo3 0.28.3 crate/::typesrust-analyzer cargo pyo3 0.28.3 types/::PyDictrust-analyzer cargo pyo3 0.28.3 types/dict/PyDict#::newrust-analyzer cargo pyo3 0.28.3 types/dict/impl#[PyDict]new().(py);
2430 for (k, v) in self.itemsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]items().() {
2431 d.set_itemrust-analyzer cargo pyo3 0.28.3 types/dict/impl#[`Bound<'py, PyDict>`][`PyDictMethods<'py>`]set_item().(k, v)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
2432 }
2433 let m = py.importrust-analyzer cargo pyo3 0.28.3 marker/impl#[`Python<'py>`]import().("debian.deb822")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
2434 let cls = m.getattrrust-analyzer cargo pyo3 0.28.3 types/any/impl#[`Bound<'py, PyAny>`][`PyAnyMethods<'py>`]getattr().("Deb822")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
2435 cls.call1rust-analyzer cargo pyo3 0.28.3 types/any/impl#[`Bound<'py, PyAny>`][`PyAnyMethods<'py>`]call1().((d,))
2436 }
2437 }
2438
2439 #[cfg(feature = "python-debian")]
2440 impl<'py> pyo3rust-analyzer cargo pyo3 0.28.3 crate/::FromPyObjectrust-analyzer cargo pyo3 0.28.3 conversion/FromPyObject#<'_, 'py> for Paragraphrust-analyzer cargo deb822-lossless 0.5.18 lossless/Paragraph# {
2441 type Errorrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph][`FromPyObject<'_, 'py>`]Error# = pyo3rust-analyzer cargo pyo3 0.28.3 crate/::PyErrrust-analyzer cargo pyo3 0.28.3 err/PyErr#;
2442
2443 fn extractrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph][`FromPyObject<'_, 'py>`]extract().(obj: pyo3rust-analyzer cargo pyo3 0.28.3 crate/::Borrowedrust-analyzer cargo pyo3 0.28.3 instance/Borrowed#<'_, 'py, pyo3rust-analyzer cargo pyo3 0.28.3 crate/::PyAnyrust-analyzer cargo pyo3 0.28.3 types/any/PyAny#>) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph][`FromPyObject<'_, 'py>`], Selfrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph][`FromPyObject<'_, 'py>`]::Errorrust-analyzer cargo pyo3 0.28.3 conversion/FromPyObject#Error#> {
2444 use pyo3rust-analyzer cargo pyo3 0.28.3 crate/::typesrust-analyzer cargo pyo3 0.28.3 types/::PyAnyMethodsrust-analyzer cargo pyo3 0.28.3 types/any/PyAnyMethods#;
2445 let d = obj.call_method0rust-analyzer cargo pyo3 0.28.3 types/any/impl#[`Bound<'py, PyAny>`][`PyAnyMethods<'py>`]call_method0().("__str__")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()..extractrust-analyzer cargo pyo3 0.28.3 types/any/impl#[`Bound<'py, PyAny>`][`PyAnyMethods<'py>`]extract().::<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
2446 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().(&d)
2447 .map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(|e| pyo3rust-analyzer cargo pyo3 0.28.3 crate/::exceptionsrust-analyzer cargo pyo3 0.28.3 exceptions/::PyValueErrorrust-analyzer cargo pyo3 0.28.3 exceptions/PyValueError#::new_errrust-analyzer cargo pyo3 0.28.3 exceptions/impl#[PyValueError]new_err().((e.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(),)))
2448 }
2449 }
2450
2451 impl Entryrust-analyzer cargo deb822-lossless 0.5.18 lossless/Entry# {
2452 /// Capture an independent snapshot of this entry.
2453 ///
2454 /// See [`Deb822::snapshot`] for details.
2455 pub fn snapshotrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]snapshot().(&self) -> Selfrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry] {
2456 Entryrust-analyzer cargo deb822-lossless 0.5.18 lossless/Entry#(SyntaxNoderust-analyzer cargo deb822-lossless 0.5.18 lossless/SyntaxNode#::new_root_mutrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]new_root_mut().(self.0rust-analyzer cargo deb822-lossless 0.5.18 lossless/Entry#0..greenrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]green().().into_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/impl#[`Cow<'_, B>`]into_owned().()))
2457 }
2458
2459 /// O(1) check: returns true iff `self` and `snapshot` reference the same
2460 /// syntax-tree state. See [`Deb822::tree_eq`].
2461 pub fn tree_eqrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]tree_eq().(&self, other: &Selfrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]) -> bool {
2462 green_eqrust-analyzer cargo deb822-lossless 0.5.18 lossless/green_eq().(&self.0rust-analyzer cargo deb822-lossless 0.5.18 lossless/Entry#0., &other.0rust-analyzer cargo deb822-lossless 0.5.18 lossless/Entry#0.)
2463 }
2464
2465 /// Returns the text range of this entry in the source text.
2466 pub fn text_rangerust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]text_range().(&self) -> rowanrust-analyzer cargo rowan 0.16.1 crate/::TextRangerust-analyzer cargo text-size 1.1.1 range/TextRange# {
2467 self.0rust-analyzer cargo deb822-lossless 0.5.18 lossless/Entry#0..text_rangerust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]text_range().()
2468 }
2469
2470 /// Returns the text range of the key (field name) in this entry.
2471 pub fn key_rangerust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]key_range().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<rowanrust-analyzer cargo rowan 0.16.1 crate/::TextRangerust-analyzer cargo text-size 1.1.1 range/TextRange#> {
2472 self.0rust-analyzer cargo deb822-lossless 0.5.18 lossless/Entry#0.
2473 .children_with_tokensrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]children_with_tokens().()
2474 .filter_maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#filter_map().(|it| it.into_tokenrust-analyzer cargo rowan 0.16.1 utility_types/impl#[`NodeOrToken<N, T>`]into_token().())
2475 .findrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#find().(|it| it.kindrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxToken<L>`]kind().() rust-analyzer cargo deb822-lossless 0.5.18 lex/impl#[SyntaxKind][`PartialEq<Self>`]eq().==rust-analyzer cargo deb822-lossless 0.5.18 lex/impl#[SyntaxKind][`PartialEq<Self>`]eq(). rust-analyzer cargo deb822-lossless 0.5.18 lex/impl#[SyntaxKind][`PartialEq<Self>`]eq().KEYrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#KEY#)
2476 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|it| it.text_rangerust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxToken<L>`]text_range().())
2477 }
2478
2479 /// Returns the text range of the colon separator in this entry.
2480 pub fn colon_rangerust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]colon_range().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<rowanrust-analyzer cargo rowan 0.16.1 crate/::TextRangerust-analyzer cargo text-size 1.1.1 range/TextRange#> {
2481 self.0rust-analyzer cargo deb822-lossless 0.5.18 lossless/Entry#0.
2482 .children_with_tokensrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]children_with_tokens().()
2483 .filter_maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#filter_map().(|it| it.into_tokenrust-analyzer cargo rowan 0.16.1 utility_types/impl#[`NodeOrToken<N, T>`]into_token().())
2484 .findrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#find().(|it| it.kindrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxToken<L>`]kind().() rust-analyzer cargo deb822-lossless 0.5.18 lex/impl#[SyntaxKind][`PartialEq<Self>`]eq().==rust-analyzer cargo deb822-lossless 0.5.18 lex/impl#[SyntaxKind][`PartialEq<Self>`]eq(). rust-analyzer cargo deb822-lossless 0.5.18 lex/impl#[SyntaxKind][`PartialEq<Self>`]eq().COLONrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#COLON#)
2485 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|it| it.text_rangerust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxToken<L>`]text_range().())
2486 }
2487
2488 /// Returns the text range of the value portion (excluding the key and colon) in this entry.
2489 /// This includes all VALUE tokens and any continuation lines.
2490 pub fn value_rangerust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]value_range().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<rowanrust-analyzer cargo rowan 0.16.1 crate/::TextRangerust-analyzer cargo text-size 1.1.1 range/TextRange#> {
2491 let value_tokens: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_> = self
2492 .0rust-analyzer cargo deb822-lossless 0.5.18 lossless/Entry#0.
2493 .children_with_tokensrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]children_with_tokens().()
2494 .filter_maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#filter_map().(|it| it.into_tokenrust-analyzer cargo rowan 0.16.1 utility_types/impl#[`NodeOrToken<N, T>`]into_token().())
2495 .filterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#filter().(|it| it.kindrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxToken<L>`]kind().() rust-analyzer cargo deb822-lossless 0.5.18 lex/impl#[SyntaxKind][`PartialEq<Self>`]eq().==rust-analyzer cargo deb822-lossless 0.5.18 lex/impl#[SyntaxKind][`PartialEq<Self>`]eq(). rust-analyzer cargo deb822-lossless 0.5.18 lex/impl#[SyntaxKind][`PartialEq<Self>`]eq().VALUErust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#VALUE#)
2496 .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().();
2497
2498 if value_tokens.is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().() {
2499 return Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#;
2500 }
2501
2502 let first = value_tokens.firstrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]first().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().();
2503 let last = value_tokens.lastrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]last().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().();
2504 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(rowanrust-analyzer cargo rowan 0.16.1 crate/::TextRangerust-analyzer cargo text-size 1.1.1 range/TextRange#::newrust-analyzer cargo text-size 1.1.1 range/impl#[TextRange]new().(
2505 first.text_rangerust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxToken<L>`]text_range().().startrust-analyzer cargo text-size 1.1.1 range/impl#[TextRange]start().(),
2506 last.text_rangerust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxToken<L>`]text_range().().endrust-analyzer cargo text-size 1.1.1 range/impl#[TextRange]end().(),
2507 ))
2508 }
2509
2510 /// Returns the text ranges of all individual value lines in this entry.
2511 /// Multi-line values will return multiple ranges.
2512 pub fn value_line_rangesrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]value_line_ranges().(&self) -> Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<rowanrust-analyzer cargo rowan 0.16.1 crate/::TextRangerust-analyzer cargo text-size 1.1.1 range/TextRange#> {
2513 self.0rust-analyzer cargo deb822-lossless 0.5.18 lossless/Entry#0.
2514 .children_with_tokensrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]children_with_tokens().()
2515 .filter_maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#filter_map().(|it| it.into_tokenrust-analyzer cargo rowan 0.16.1 utility_types/impl#[`NodeOrToken<N, T>`]into_token().())
2516 .filterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#filter().(|it| it.kindrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxToken<L>`]kind().() rust-analyzer cargo deb822-lossless 0.5.18 lex/impl#[SyntaxKind][`PartialEq<Self>`]eq().==rust-analyzer cargo deb822-lossless 0.5.18 lex/impl#[SyntaxKind][`PartialEq<Self>`]eq(). rust-analyzer cargo deb822-lossless 0.5.18 lex/impl#[SyntaxKind][`PartialEq<Self>`]eq().VALUErust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#VALUE#)
2517 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|it| it.text_rangerust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxToken<L>`]text_range().())
2518 .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().()
2519 }
2520
2521 /// Returns the text range of the first whitespace-delimited token of the
2522 /// value.
2523 ///
2524 /// For single-word values (e.g. `Source: hello`) this is the whole value.
2525 /// For multi-word values it covers just the first word, which is useful for
2526 /// fields whose first token is an identifier — for example the license
2527 /// short-name in a DEP-5 `License:` field (`GPL-2+ with exceptions`).
2528 /// Returns `None` if the value is empty.
2529 pub fn value_token_rangerust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]value_token_range().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<rowanrust-analyzer cargo rowan 0.16.1 crate/::TextRangerust-analyzer cargo text-size 1.1.1 range/TextRange#> {
2530 let value_range = self.value_rangerust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]value_range().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Try]branch().;
2531 let first = self
2532 .0rust-analyzer cargo deb822-lossless 0.5.18 lossless/Entry#0.
2533 .children_with_tokensrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]children_with_tokens().()
2534 .filter_maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#filter_map().(|it| it.into_tokenrust-analyzer cargo rowan 0.16.1 utility_types/impl#[`NodeOrToken<N, T>`]into_token().())
2535 .findrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#find().(|it| it.kindrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxToken<L>`]kind().() rust-analyzer cargo deb822-lossless 0.5.18 lex/impl#[SyntaxKind][`PartialEq<Self>`]eq().==rust-analyzer cargo deb822-lossless 0.5.18 lex/impl#[SyntaxKind][`PartialEq<Self>`]eq(). rust-analyzer cargo deb822-lossless 0.5.18 lex/impl#[SyntaxKind][`PartialEq<Self>`]eq().VALUErust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#VALUE#)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Try]branch().;
2536 let text = first.textrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxToken<L>`]text().();
2537 let leading_ws = text.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().text.trim_startrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]trim_start().().lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]len().();
2538 let token_len = text[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().leading_ws..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().
2539 .findrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]find().(char::is_whitespacerust-analyzer cargo core https://github.com/rust-lang/rust/library/core char/methods/impl#[char]is_whitespace().)
2540 .unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().(text.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().leading_ws);
2541 if token_len 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 {
2542 return Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#;
2543 }
2544 let start = first.text_rangerust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxToken<L>`]text_range().().startrust-analyzer cargo text-size 1.1.1 range/impl#[TextRange]start().() rust-analyzer cargo text-size 1.1.1 size/impl#[TextSize][`Add<Self>`]add().+rust-analyzer cargo text-size 1.1.1 size/impl#[TextSize][`Add<Self>`]add(). rust-analyzer cargo text-size 1.1.1 size/impl#[TextSize][`Add<Self>`]add().rowanrust-analyzer cargo rowan 0.16.1 crate/::TextSizerust-analyzer cargo text-size 1.1.1 size/TextSize#::fromrust-analyzer cargo text-size 1.1.1 size/impl#[TextSize][`From<u32>`]from().(leading_ws as u32);
2545 let end = start rust-analyzer cargo text-size 1.1.1 size/impl#[TextSize][`Add<Self>`]add().+rust-analyzer cargo text-size 1.1.1 size/impl#[TextSize][`Add<Self>`]add(). rust-analyzer cargo text-size 1.1.1 size/impl#[TextSize][`Add<Self>`]add().rowanrust-analyzer cargo rowan 0.16.1 crate/::TextSizerust-analyzer cargo text-size 1.1.1 size/TextSize#::fromrust-analyzer cargo text-size 1.1.1 size/impl#[TextSize][`From<u32>`]from().(token_len as u32);
2546 // Defensively clamp to the value range.
2547 if start 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().value_range.startrust-analyzer cargo text-size 1.1.1 range/impl#[TextRange]start().() || end 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().value_range.endrust-analyzer cargo text-size 1.1.1 range/impl#[TextRange]end().() {
2548 return Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#;
2549 }
2550 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(rowanrust-analyzer cargo rowan 0.16.1 crate/::TextRangerust-analyzer cargo text-size 1.1.1 range/TextRange#::newrust-analyzer cargo text-size 1.1.1 range/impl#[TextRange]new().(start, end))
2551 }
2552
2553 /// Create a new entry with the given key and value.
2554 pub fn newrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]new().(key: &str, value: &str) -> Entryrust-analyzer cargo deb822-lossless 0.5.18 lossless/Entry# {
2555 Selfrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]::with_indentationrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]with_indentation().(key, value, " ")
2556 }
2557
2558 /// Create a new entry with the given key, value, and custom indentation for continuation lines.
2559 ///
2560 /// # Arguments
2561 /// * `key` - The field name
2562 /// * `value` - The field value (may contain '\n' for multi-line values)
2563 /// * `indent` - The indentation string to use for continuation lines
2564 pub fn with_indentationrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]with_indentation().(key: &str, value: &str, indent: &str) -> Entryrust-analyzer cargo deb822-lossless 0.5.18 lossless/Entry# {
2565 Entryrust-analyzer cargo deb822-lossless 0.5.18 lossless/Entry#::with_formattingrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]with_formatting().(key, value, " ", indent)
2566 }
2567
2568 /// Try to create a new entry with specific formatting, validating the value.
2569 ///
2570 /// # Arguments
2571 /// * `key` - The field name
2572 /// * `value` - The field value (may contain '\n' for multi-line values)
2573 /// * `post_colon_ws` - The whitespace after the colon (e.g., " " or "\n ")
2574 /// * `indent` - The indentation string to use for continuation lines
2575 ///
2576 /// # Errors
2577 /// Returns an error if the value contains empty continuation lines (lines with only whitespace)
2578 pub fn try_with_formattingrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]try_with_formatting().(
2579 key: &str,
2580 value: &str,
2581 post_colon_ws: &str,
2582 indent: &str,
2583 ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Entryrust-analyzer cargo deb822-lossless 0.5.18 lossless/Entry#, Errorrust-analyzer cargo deb822-lossless 0.5.18 lossless/Error#> {
2584 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().();
2585
2586 builder.start_noderust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]start_node().(ENTRYrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#ENTRY#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
2587 builder.tokenrust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]token().(KEYrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#KEY#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), key);
2588 builder.tokenrust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]token().(COLONrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#COLON#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), ":");
2589
2590 // Add the post-colon whitespace token by token
2591 let mut i = 0;
2592 while i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().post_colon_ws.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]len().() {
2593 if post_colon_ws[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().i..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..starts_withrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]starts_with().('\n') {
2594 builder.tokenrust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]token().(NEWLINErust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#NEWLINE#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), "\n");
2595 i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().1;
2596 } else {
2597 // Collect consecutive non-newline chars as WHITESPACE
2598 let start = i;
2599 while i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().post_colon_ws.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]len().() && !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().post_colon_ws[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().i..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..starts_withrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]starts_with().('\n') {
2600 i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().post_colon_ws[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().i..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..charsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]chars().().nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/iter/impl#[`Chars<'a>`][Iterator]next().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().len_utf8rust-analyzer cargo core https://github.com/rust-lang/rust/library/core char/methods/impl#[char]len_utf8().();
2601 }
2602 builder.tokenrust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]token().(WHITESPACErust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#WHITESPACE#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), &post_colon_ws[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().start..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#i]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().);
2603 }
2604 }
2605
2606 for (line_idx, line) in value.splitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]split().('\n').enumeraterust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#enumerate().() {
2607 if line_idx 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 {
2608 // Validate that continuation lines are not empty or whitespace-only
2609 // According to Debian Policy, continuation lines must have content
2610 if line.trimrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]trim().().is_emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]is_empty().() {
2611 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo deb822-lossless 0.5.18 lossless/Error#::InvalidValuerust-analyzer cargo deb822-lossless 0.5.18 lossless/Error#InvalidValue#(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!(
2612 "empty continuation line (line with only whitespace) at line {}",
2613 line_idx +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). 1
2614 )));
2615 }
2616 builder.tokenrust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]token().(INDENTrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#INDENT#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), indent);
2617 }
2618 builder.tokenrust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]token().(VALUErust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#VALUE#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), line);
2619 builder.tokenrust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]token().(NEWLINErust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#NEWLINE#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), "\n");
2620 }
2621 builder.finish_noderust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]finish_node().();
2622 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Entryrust-analyzer cargo deb822-lossless 0.5.18 lossless/Entry#(SyntaxNoderust-analyzer cargo deb822-lossless 0.5.18 lossless/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().())))
2623 }
2624
2625 /// Create a new entry with specific formatting for post-colon whitespace and indentation.
2626 ///
2627 /// # Arguments
2628 /// * `key` - The field name
2629 /// * `value` - The field value (may contain '\n' for multi-line values)
2630 /// * `post_colon_ws` - The whitespace after the colon (e.g., " " or "\n ")
2631 /// * `indent` - The indentation string to use for continuation lines
2632 ///
2633 /// # Panics
2634 /// Panics if the value contains empty continuation lines (lines with only whitespace)
2635 pub fn with_formattingrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]with_formatting().(key: &str, value: &str, post_colon_ws: &str, indent: &str) -> Entryrust-analyzer cargo deb822-lossless 0.5.18 lossless/Entry# {
2636 Selfrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]::try_with_formattingrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]try_with_formatting().(key, value, post_colon_ws, indent)
2637 .expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("Invalid value: empty continuation line")
2638 }
2639
2640 #[must_use]
2641 /// Reformat this entry
2642 ///
2643 /// # Arguments
2644 /// * `indentation` - The indentation to use
2645 /// * `immediate_empty_line` - Whether multi-line values should always start with an empty line
2646 /// * `max_line_length_one_liner` - If set, then this is the max length of the value if it is
2647 /// crammed into a "one-liner" value
2648 /// * `format_value` - If set, then this function will format the value according to the given
2649 /// function
2650 ///
2651 /// # Returns
2652 /// The reformatted entry
2653 pub fn wrap_and_sortrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]wrap_and_sort().(
2654 &self,
2655 mut indentation: Indentationrust-analyzer cargo deb822-lossless 0.5.18 Indentation#,
2656 immediate_empty_line: bool,
2657 max_line_length_one_liner: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<usize>,
2658 format_value: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&dyn Fnrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/function/Fn#(&str, &str) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>,
2659 ) -> Entryrust-analyzer cargo deb822-lossless 0.5.18 lossless/Entry# {
2660 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().();
2661
2662 let mut content = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![];
2663 builder.start_noderust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]start_node().(ENTRYrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#ENTRY#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
2664 for c in self.0rust-analyzer cargo deb822-lossless 0.5.18 lossless/Entry#0..children_with_tokensrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]children_with_tokens().() {
2665 let text = c.as_tokenrust-analyzer cargo rowan 0.16.1 utility_types/impl#[`NodeOrToken<N, T>`]as_token().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|t| t.textrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxToken<L>`]text().());
2666 match c.kindrust-analyzer cargo rowan 0.16.1 api/impl#[`NodeOrToken<SyntaxNode<L>, SyntaxToken<L>>`]kind().() {
2667 KEYrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#KEY# => {
2668 builder.tokenrust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]token().(KEYrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#KEY#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), text.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().());
2669 if indentation rust-analyzer cargo deb822-lossless 0.5.18 impl#[Indentation][`PartialEq<Self>`]eq().==rust-analyzer cargo deb822-lossless 0.5.18 impl#[Indentation][`PartialEq<Self>`]eq(). rust-analyzer cargo deb822-lossless 0.5.18 impl#[Indentation][`PartialEq<Self>`]eq().Indentationrust-analyzer cargo deb822-lossless 0.5.18 Indentation#::FieldNameLengthrust-analyzer cargo deb822-lossless 0.5.18 Indentation#FieldNameLength# {
2670 indentation = Indentationrust-analyzer cargo deb822-lossless 0.5.18 Indentation#::Spacesrust-analyzer cargo deb822-lossless 0.5.18 Indentation#Spaces#(text.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]len().() as u32);
2671 }
2672 }
2673 COLONrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#COLON# => {
2674 builder.tokenrust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]token().(COLONrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#COLON#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), ":");
2675 }
2676 INDENTrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#INDENT# => {
2677 // Discard original whitespace
2678 }
2679 ERRORrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#ERROR# | COMMENTrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#COMMENT# | VALUErust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#VALUE# | WHITESPACErust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#WHITESPACE# | NEWLINErust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#NEWLINE# => {
2680 content.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(c);
2681 }
2682 EMPTY_LINErust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#EMPTY_LINE# | ENTRYrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#ENTRY# | ROOTrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#ROOT# | PARAGRAPHrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#PARAGRAPH# => unreachablerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/unreachable!!(),
2683 }
2684 }
2685
2686 let indentation = if let craterust-analyzer cargo deb822-lossless 0.5.18 crate/::Indentationrust-analyzer cargo deb822-lossless 0.5.18 Indentation#::Spacesrust-analyzer cargo deb822-lossless 0.5.18 Indentation#Spaces#(i) = indentation {
2687 i
2688 } else {
2689 1
2690 };
2691
2692 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(indentation >rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialOrd<Self>`]gt(). 0);
2693
2694 // Strip trailing whitespace and newlines
2695 while let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(c) = content.lastrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]last().() {
2696 if c.kindrust-analyzer cargo rowan 0.16.1 api/impl#[`NodeOrToken<SyntaxNode<L>, SyntaxToken<L>>`]kind().() rust-analyzer cargo deb822-lossless 0.5.18 lex/impl#[SyntaxKind][`PartialEq<Self>`]eq().==rust-analyzer cargo deb822-lossless 0.5.18 lex/impl#[SyntaxKind][`PartialEq<Self>`]eq(). rust-analyzer cargo deb822-lossless 0.5.18 lex/impl#[SyntaxKind][`PartialEq<Self>`]eq().NEWLINErust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#NEWLINE# || c.kindrust-analyzer cargo rowan 0.16.1 api/impl#[`NodeOrToken<SyntaxNode<L>, SyntaxToken<L>>`]kind().() rust-analyzer cargo deb822-lossless 0.5.18 lex/impl#[SyntaxKind][`PartialEq<Self>`]eq().==rust-analyzer cargo deb822-lossless 0.5.18 lex/impl#[SyntaxKind][`PartialEq<Self>`]eq(). rust-analyzer cargo deb822-lossless 0.5.18 lex/impl#[SyntaxKind][`PartialEq<Self>`]eq().WHITESPACErust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#WHITESPACE# {
2697 content.poprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]pop().();
2698 } else {
2699 break;
2700 }
2701 }
2702
2703 // Reformat iff there is a format function and the value
2704 // has no errors or comments
2705 let tokens = if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(ref format_value) = format_value {
2706 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().content
2707 .iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().()
2708 .anyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]any().(|c| c.kindrust-analyzer cargo rowan 0.16.1 api/impl#[`NodeOrToken<SyntaxNode<L>, SyntaxToken<L>>`]kind().() rust-analyzer cargo deb822-lossless 0.5.18 lex/impl#[SyntaxKind][`PartialEq<Self>`]eq().==rust-analyzer cargo deb822-lossless 0.5.18 lex/impl#[SyntaxKind][`PartialEq<Self>`]eq(). rust-analyzer cargo deb822-lossless 0.5.18 lex/impl#[SyntaxKind][`PartialEq<Self>`]eq().ERRORrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#ERROR# || c.kindrust-analyzer cargo rowan 0.16.1 api/impl#[`NodeOrToken<SyntaxNode<L>, SyntaxToken<L>>`]kind().() rust-analyzer cargo deb822-lossless 0.5.18 lex/impl#[SyntaxKind][`PartialEq<Self>`]eq().==rust-analyzer cargo deb822-lossless 0.5.18 lex/impl#[SyntaxKind][`PartialEq<Self>`]eq(). rust-analyzer cargo deb822-lossless 0.5.18 lex/impl#[SyntaxKind][`PartialEq<Self>`]eq().COMMENTrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#COMMENT#)
2709 {
2710 let concat = content
2711 .iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().()
2712 .filter_maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#filter_map().(|c| c.as_tokenrust-analyzer cargo rowan 0.16.1 utility_types/impl#[`NodeOrToken<N, T>`]as_token().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|t| t.textrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxToken<L>`]text().()))
2713 .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>();
2714 let formatted = format_value(self.keyrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]key().().as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), &concat);
2715 craterust-analyzer cargo deb822-lossless 0.5.18 crate/::lexrust-analyzer cargo deb822-lossless 0.5.18 lex/::lex_inlinerust-analyzer cargo deb822-lossless 0.5.18 lex/lex_inline().(&formatted)
2716 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|(k, t)| (k, t.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()))
2717 .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#<_>>()
2718 } else {
2719 content
2720 .into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().()
2721 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|n| n.into_tokenrust-analyzer cargo rowan 0.16.1 utility_types/impl#[`NodeOrToken<N, T>`]into_token().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().())
2722 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|i| (i.kindrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxToken<L>`]kind().(), i.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().()))
2723 .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#<_>>()
2724 }
2725 } else {
2726 content
2727 .into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().()
2728 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|n| n.into_tokenrust-analyzer cargo rowan 0.16.1 utility_types/impl#[`NodeOrToken<N, T>`]into_token().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().())
2729 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|i| (i.kindrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxToken<L>`]kind().(), i.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().()))
2730 .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#<_>>()
2731 };
2732
2733 rebuild_valuerust-analyzer cargo deb822-lossless 0.5.18 lossless/rebuild_value().(
2734 &mut builder,
2735 tokens,
2736 self.keyrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]key().().map_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map_or().(0, |k| k.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]len().()),
2737 indentation,
2738 immediate_empty_line,
2739 max_line_length_one_liner,
2740 );
2741
2742 builder.finish_noderust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]finish_node().();
2743 Selfrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry](SyntaxNoderust-analyzer cargo deb822-lossless 0.5.18 lossless/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().()))
2744 }
2745
2746 /// Returns the key of the entry.
2747 pub fn keyrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]key().(&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#> {
2748 self.0rust-analyzer cargo deb822-lossless 0.5.18 lossless/Entry#0.
2749 .children_with_tokensrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]children_with_tokens().()
2750 .filter_maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#filter_map().(|it| it.into_tokenrust-analyzer cargo rowan 0.16.1 utility_types/impl#[`NodeOrToken<N, T>`]into_token().())
2751 .findrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#find().(|it| it.kindrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxToken<L>`]kind().() rust-analyzer cargo deb822-lossless 0.5.18 lex/impl#[SyntaxKind][`PartialEq<Self>`]eq().==rust-analyzer cargo deb822-lossless 0.5.18 lex/impl#[SyntaxKind][`PartialEq<Self>`]eq(). rust-analyzer cargo deb822-lossless 0.5.18 lex/impl#[SyntaxKind][`PartialEq<Self>`]eq().KEYrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#KEY#)
2752 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|it| it.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().())
2753 }
2754
2755 /// Returns the value of the entry.
2756 pub fn valuerust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]value().(&self) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# {
2757 let mut parts = self
2758 .0rust-analyzer cargo deb822-lossless 0.5.18 lossless/Entry#0.
2759 .children_with_tokensrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]children_with_tokens().()
2760 .filter_maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#filter_map().(|it| it.into_tokenrust-analyzer cargo rowan 0.16.1 utility_types/impl#[`NodeOrToken<N, T>`]into_token().())
2761 .filterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#filter().(|it| it.kindrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxToken<L>`]kind().() rust-analyzer cargo deb822-lossless 0.5.18 lex/impl#[SyntaxKind][`PartialEq<Self>`]eq().==rust-analyzer cargo deb822-lossless 0.5.18 lex/impl#[SyntaxKind][`PartialEq<Self>`]eq(). rust-analyzer cargo deb822-lossless 0.5.18 lex/impl#[SyntaxKind][`PartialEq<Self>`]eq().VALUErust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#VALUE#)
2762 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|it| it.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().());
2763
2764 match parts.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/map/impl#[`Map<I, F>`][Iterator]next().() {
2765 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]new().(),
2766 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(first) => {
2767 let mut result = first;
2768 for part in parts {
2769 result.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push().('\n');
2770 result.push_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push_str().(&part);
2771 }
2772 result
2773 }
2774 }
2775 }
2776
2777 /// Returns the value of this entry, including any comment lines embedded
2778 /// within the multi-line value.
2779 ///
2780 /// This is like [`value()`](Self::value) but also includes `#`-prefixed
2781 /// comment lines that appear between continuation lines. This is useful
2782 /// for parsers (e.g. Relations) that need to preserve commented-out entries.
2783 pub fn value_with_commentsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]value_with_comments().(&self) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# {
2784 let mut parts = self
2785 .0rust-analyzer cargo deb822-lossless 0.5.18 lossless/Entry#0.
2786 .children_with_tokensrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]children_with_tokens().()
2787 .filter_maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#filter_map().(|it| it.into_tokenrust-analyzer cargo rowan 0.16.1 utility_types/impl#[`NodeOrToken<N, T>`]into_token().())
2788 .filterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#filter().(|it| it.kindrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxToken<L>`]kind().() rust-analyzer cargo deb822-lossless 0.5.18 lex/impl#[SyntaxKind][`PartialEq<Self>`]eq().==rust-analyzer cargo deb822-lossless 0.5.18 lex/impl#[SyntaxKind][`PartialEq<Self>`]eq(). rust-analyzer cargo deb822-lossless 0.5.18 lex/impl#[SyntaxKind][`PartialEq<Self>`]eq().VALUErust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#VALUE# || it.kindrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxToken<L>`]kind().() rust-analyzer cargo deb822-lossless 0.5.18 lex/impl#[SyntaxKind][`PartialEq<Self>`]eq().==rust-analyzer cargo deb822-lossless 0.5.18 lex/impl#[SyntaxKind][`PartialEq<Self>`]eq(). rust-analyzer cargo deb822-lossless 0.5.18 lex/impl#[SyntaxKind][`PartialEq<Self>`]eq().COMMENTrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#COMMENT#)
2789 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|it| it.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().());
2790
2791 match parts.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/map/impl#[`Map<I, F>`][Iterator]next().() {
2792 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]new().(),
2793 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(first) => {
2794 let mut result = first;
2795 for part in parts {
2796 result.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push().('\n');
2797 result.push_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push_str().(&part);
2798 }
2799 result
2800 }
2801 }
2802 }
2803
2804 /// Returns the indentation string used for continuation lines in this entry.
2805 /// Returns None if the entry has no continuation lines.
2806 fn get_indentrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]get_indent().(&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#> {
2807 self.0rust-analyzer cargo deb822-lossless 0.5.18 lossless/Entry#0.
2808 .children_with_tokensrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]children_with_tokens().()
2809 .filter_maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#filter_map().(|it| it.into_tokenrust-analyzer cargo rowan 0.16.1 utility_types/impl#[`NodeOrToken<N, T>`]into_token().())
2810 .findrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#find().(|it| it.kindrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxToken<L>`]kind().() rust-analyzer cargo deb822-lossless 0.5.18 lex/impl#[SyntaxKind][`PartialEq<Self>`]eq().==rust-analyzer cargo deb822-lossless 0.5.18 lex/impl#[SyntaxKind][`PartialEq<Self>`]eq(). rust-analyzer cargo deb822-lossless 0.5.18 lex/impl#[SyntaxKind][`PartialEq<Self>`]eq().INDENTrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#INDENT#)
2811 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|it| it.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().())
2812 }
2813
2814 /// Returns the whitespace immediately after the colon in this entry.
2815 /// This includes WHITESPACE, NEWLINE, and INDENT tokens up to the first VALUE token.
2816 /// Returns None if there is no whitespace (which would be malformed).
2817 fn get_post_colon_whitespacerust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]get_post_colon_whitespace().(&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#> {
2818 let mut found_colon = false;
2819 let mut whitespace = Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]new().();
2820
2821 for token in self
2822 .0rust-analyzer cargo deb822-lossless 0.5.18 lossless/Entry#0.
2823 .children_with_tokensrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]children_with_tokens().()
2824 .filter_maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#filter_map().(|it| it.into_tokenrust-analyzer cargo rowan 0.16.1 utility_types/impl#[`NodeOrToken<N, T>`]into_token().())
2825 {
2826 if token.kindrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxToken<L>`]kind().() rust-analyzer cargo deb822-lossless 0.5.18 lex/impl#[SyntaxKind][`PartialEq<Self>`]eq().==rust-analyzer cargo deb822-lossless 0.5.18 lex/impl#[SyntaxKind][`PartialEq<Self>`]eq(). rust-analyzer cargo deb822-lossless 0.5.18 lex/impl#[SyntaxKind][`PartialEq<Self>`]eq().COLONrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#COLON# {
2827 found_colon = true;
2828 continue;
2829 }
2830
2831 if found_colon {
2832 if token.kindrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxToken<L>`]kind().() rust-analyzer cargo deb822-lossless 0.5.18 lex/impl#[SyntaxKind][`PartialEq<Self>`]eq().==rust-analyzer cargo deb822-lossless 0.5.18 lex/impl#[SyntaxKind][`PartialEq<Self>`]eq(). rust-analyzer cargo deb822-lossless 0.5.18 lex/impl#[SyntaxKind][`PartialEq<Self>`]eq().WHITESPACErust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#WHITESPACE# || token.kindrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxToken<L>`]kind().() rust-analyzer cargo deb822-lossless 0.5.18 lex/impl#[SyntaxKind][`PartialEq<Self>`]eq().==rust-analyzer cargo deb822-lossless 0.5.18 lex/impl#[SyntaxKind][`PartialEq<Self>`]eq(). rust-analyzer cargo deb822-lossless 0.5.18 lex/impl#[SyntaxKind][`PartialEq<Self>`]eq().NEWLINErust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#NEWLINE# || token.kindrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxToken<L>`]kind().() rust-analyzer cargo deb822-lossless 0.5.18 lex/impl#[SyntaxKind][`PartialEq<Self>`]eq().==rust-analyzer cargo deb822-lossless 0.5.18 lex/impl#[SyntaxKind][`PartialEq<Self>`]eq(). rust-analyzer cargo deb822-lossless 0.5.18 lex/impl#[SyntaxKind][`PartialEq<Self>`]eq().INDENTrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#INDENT# {
2833 whitespace.push_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push_str().(token.textrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxToken<L>`]text().());
2834 } else {
2835 // We've reached a non-whitespace token, stop collecting
2836 break;
2837 }
2838 }
2839 }
2840
2841 if whitespace.is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]is_empty().() {
2842 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#
2843 } else {
2844 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(whitespace)
2845 }
2846 }
2847
2848 /// Normalize the spacing around the field separator (colon) in place.
2849 ///
2850 /// This ensures that there is exactly one space after the colon and before the value.
2851 /// This is a lossless operation that preserves the field name and value content,
2852 /// but normalizes the whitespace formatting.
2853 ///
2854 /// # Examples
2855 ///
2856 /// ```
2857 /// use deb822_lossless::Deb822;
2858 /// use std::str::FromStr;
2859 ///
2860 /// // Parse an entry with extra spacing after the colon
2861 /// let input = "Field: value\n";
2862 /// let mut deb822 = Deb822::from_str(input).unwrap();
2863 /// let mut para = deb822.paragraphs().next().unwrap();
2864 ///
2865 /// para.normalize_field_spacing();
2866 /// assert_eq!(para.get("Field").as_deref(), Some("value"));
2867 /// ```
2868 pub fn normalize_field_spacingrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]normalize_field_spacing().(&mut self) -> bool {
2869 use rowanrust-analyzer cargo rowan 0.16.1 crate/::GreenNodeBuilderrust-analyzer cargo rowan 0.16.1 green/builder/GreenNodeBuilder#;
2870
2871 // Store the original text for comparison
2872 let original_text = self.0rust-analyzer cargo deb822-lossless 0.5.18 lossless/Entry#0..textrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]text().().to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().();
2873
2874 // Build normalized entry
2875 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().();
2876 builder.start_noderust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]start_node().(ENTRYrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#ENTRY#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
2877
2878 let mut seen_colon = false;
2879 let mut skip_whitespace = false;
2880
2881 for child in self.0rust-analyzer cargo deb822-lossless 0.5.18 lossless/Entry#0..children_with_tokensrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]children_with_tokens().() {
2882 match child.kindrust-analyzer cargo rowan 0.16.1 api/impl#[`NodeOrToken<SyntaxNode<L>, SyntaxToken<L>>`]kind().() {
2883 KEYrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#KEY# => {
2884 builder.tokenrust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]token().(KEYrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#KEY#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), child.as_tokenrust-analyzer cargo rowan 0.16.1 utility_types/impl#[`NodeOrToken<N, T>`]as_token().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().textrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxToken<L>`]text().());
2885 }
2886 COLONrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#COLON# => {
2887 builder.tokenrust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]token().(COLONrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#COLON#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), ":");
2888 seen_colon = true;
2889 skip_whitespace = true;
2890 }
2891 WHITESPACErust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#WHITESPACE# if skip_whitespace => {
2892 // Skip existing whitespace after colon
2893 continue;
2894 }
2895 VALUErust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#VALUE# if skip_whitespace => {
2896 // Add exactly one space before the first value token
2897 builder.tokenrust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]token().(WHITESPACErust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#WHITESPACE#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), " ");
2898 builder.tokenrust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]token().(VALUErust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#VALUE#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), child.as_tokenrust-analyzer cargo rowan 0.16.1 utility_types/impl#[`NodeOrToken<N, T>`]as_token().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().textrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxToken<L>`]text().());
2899 skip_whitespace = false;
2900 }
2901 NEWLINErust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#NEWLINE# if skip_whitespace && seen_colon => {
2902 // Empty value case (e.g., "Field:\n" or "Field: \n")
2903 // Normalize to no trailing space - just output newline
2904 builder.tokenrust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]token().(NEWLINErust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#NEWLINE#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), "\n");
2905 skip_whitespace = false;
2906 }
2907 _ => {
2908 // Copy all other tokens as-is
2909 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(token) = child.as_tokenrust-analyzer cargo rowan 0.16.1 utility_types/impl#[`NodeOrToken<N, T>`]as_token().() {
2910 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().());
2911 }
2912 }
2913 }
2914 }
2915
2916 builder.finish_noderust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]finish_node().();
2917 let normalized_green = builder.finishrust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]finish().();
2918 let normalized = SyntaxNoderust-analyzer cargo deb822-lossless 0.5.18 lossless/SyntaxNode#::new_root_mutrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]new_root_mut().(normalized_green);
2919
2920 // Check if normalization made any changes
2921 let changed = original_text 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().normalized.textrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]text().().to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().();
2922
2923 if changed {
2924 // Replace this entry in place
2925 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(parent) = self.0rust-analyzer cargo deb822-lossless 0.5.18 lossless/Entry#0..parentrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]parent().() {
2926 let index = self.0rust-analyzer cargo deb822-lossless 0.5.18 lossless/Entry#0..indexrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]index().();
2927 parent.splice_childrenrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]splice_children().(index..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#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, vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![normalized.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()]);
2928 }
2929 }
2930
2931 changed
2932 }
2933
2934 /// Detach this entry from the paragraph.
2935 pub fn detachrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]detach().(&mut self) {
2936 self.0rust-analyzer cargo deb822-lossless 0.5.18 lossless/Entry#0..detachrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]detach().();
2937 }
2938 }
2939
2940 impl FromStrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/traits/FromStr# for Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822# {
2941 type Errrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822][FromStr]Err# = ParseErrorrust-analyzer cargo deb822-lossless 0.5.18 lossless/ParseError#;
2942
2943 fn from_strrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822][FromStr]from_str().(s: &str) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822][FromStr], Selfrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822][FromStr]::Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/traits/FromStr#Err#> {
2944 Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#::parserust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]parse().(s).to_resultrust-analyzer cargo deb822-lossless 0.5.18 parse/impl#[`Parse<T>`]to_result().()
2945 }
2946 }
2947
2948 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
2949 fn test_parse_simplerust-analyzer cargo deb822-lossless 0.5.18 lossless/test_parse_simple().() {
2950 const CONTROLV1rust-analyzer cargo deb822-lossless 0.5.18 lossless/CONTROLV1.: &str = r#"Source: foo
2951 Maintainer: Foo Bar <[email protected]>
2952 Section: net
2953
2954 # This is a comment
2955
2956 Package: foo
2957 Architecture: all
2958 Depends:
2959 bar,
2960 blah
2961 Description: This is a description
2962 And it is
2963 .
2964 multiple
2965 lines
2966 "#;
2967 let parsed = parserust-analyzer cargo deb822-lossless 0.5.18 lossless/parse().(CONTROLV1rust-analyzer cargo deb822-lossless 0.5.18 lossless/CONTROLV1.);
2968 let node = parsed.syntaxrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Parse]syntax().();
2969 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
2970 formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{:#?}", node),
2971 r###"[email protected]
2972 [email protected]
2973 [email protected]
2974 [email protected] "Source"
2975 [email protected] ":"
2976 [email protected] " "
2977 [email protected] "foo"
2978 [email protected] "\n"
2979 [email protected]
2980 [email protected] "Maintainer"
2981 [email protected] ":"
2982 [email protected] " "
2983 [email protected] "Foo Bar <foo@example. ..."
2984 [email protected] "\n"
2985 [email protected]
2986 [email protected] "Section"
2987 [email protected] ":"
2988 [email protected] " "
2989 [email protected] "net"
2990 [email protected] "\n"
2991 [email protected]
2992 [email protected] "\n"
2993 [email protected]
2994 [email protected] "# This is a comment"
2995 [email protected] "\n"
2996 [email protected]
2997 [email protected] "\n"
2998 [email protected]
2999 [email protected]
3000 [email protected] "Package"
3001 [email protected] ":"
3002 [email protected] " "
3003 [email protected] "foo"
3004 [email protected] "\n"
3005 [email protected]
3006 [email protected] "Architecture"
3007 [email protected] ":"
3008 [email protected] " "
3009 [email protected] "all"
3010 [email protected] "\n"
3011 [email protected]
3012 [email protected] "Depends"
3013 [email protected] ":"
3014 [email protected] "\n"
3015 [email protected] " "
3016 [email protected] "bar,"
3017 [email protected] "\n"
3018 [email protected] " "
3019 [email protected] "blah"
3020 [email protected] "\n"
3021 [email protected]
3022 [email protected] "Description"
3023 [email protected] ":"
3024 [email protected] " "
3025 [email protected] "This is a description"
3026 [email protected] "\n"
3027 [email protected] " "
3028 [email protected] "And it is"
3029 [email protected] "\n"
3030 [email protected] " "
3031 [email protected] "."
3032 [email protected] "\n"
3033 [email protected] " "
3034 [email protected] "multiple"
3035 [email protected] "\n"
3036 [email protected] " "
3037 [email protected] "lines"
3038 [email protected] "\n"
3039 "###
3040 );
3041 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(parsed.errorsrust-analyzer cargo deb822-lossless 0.5.18 lossless/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#>::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().());
3042
3043 let root = parsed.root_mutrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Parse]root_mut().();
3044 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(root.paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraphs().().countrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#count().(), 2);
3045 let source = root.paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraphs().().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().();
3046 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
3047 source.keysrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]keys().().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#<_>>(),
3048 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!!["Source", "Maintainer", "Section"]
3049 );
3050 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(source.getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("Source").as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("foo"));
3051 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
3052 source.getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("Maintainer").as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(),
3053 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("Foo Bar <[email protected]>")
3054 );
3055 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(source.getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("Section").as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("net"));
3056 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
3057 source.itemsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]items().().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#<_>>(),
3058 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![
3059 ("Source".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), "foo".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()),
3060 ("Maintainer".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), "Foo Bar <[email protected]>".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()),
3061 ("Section".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), "net".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()),
3062 ]
3063 );
3064
3065 let binary = root.paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraphs().().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().();
3066 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
3067 binary.keysrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]keys().().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#<_>>(),
3068 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!!["Package", "Architecture", "Depends", "Description"]
3069 );
3070 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(binary.getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("Package").as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("foo"));
3071 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(binary.getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("Architecture").as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("all"));
3072 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(binary.getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("Depends").as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("bar,\nblah"));
3073 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
3074 binary.getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("Description").as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(),
3075 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("This is a description\nAnd it is\n.\nmultiple\nlines")
3076 );
3077
3078 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(node.textrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]text().(), CONTROLV1rust-analyzer cargo deb822-lossless 0.5.18 lossless/CONTROLV1.);
3079 }
3080
3081 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
3082 fn test_with_trailing_whitespacerust-analyzer cargo deb822-lossless 0.5.18 lossless/test_with_trailing_whitespace().() {
3083 const CONTROLV1rust-analyzer cargo deb822-lossless 0.5.18 lossless/CONTROLV1.: &str = r#"Source: foo
3084 Maintainer: Foo Bar <[email protected]>
3085
3086
3087 "#;
3088 let parsed = parserust-analyzer cargo deb822-lossless 0.5.18 lossless/parse().(CONTROLV1rust-analyzer cargo deb822-lossless 0.5.18 lossless/CONTROLV1.);
3089 let node = parsed.syntaxrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Parse]syntax().();
3090 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
3091 formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{:#?}", node),
3092 r###"[email protected]
3093 [email protected]
3094 [email protected]
3095 [email protected] "Source"
3096 [email protected] ":"
3097 [email protected] " "
3098 [email protected] "foo"
3099 [email protected] "\n"
3100 [email protected]
3101 [email protected] "Maintainer"
3102 [email protected] ":"
3103 [email protected] " "
3104 [email protected] "Foo Bar <foo@example. ..."
3105 [email protected] "\n"
3106 [email protected]
3107 [email protected] "\n"
3108 [email protected]
3109 [email protected] "\n"
3110 "###
3111 );
3112 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(parsed.errorsrust-analyzer cargo deb822-lossless 0.5.18 lossless/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#>::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().());
3113
3114 let root = parsed.root_mutrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Parse]root_mut().();
3115 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(root.paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraphs().().countrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#count().(), 1);
3116 let source = root.paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraphs().().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().();
3117 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
3118 source.itemsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]items().().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#<_>>(),
3119 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![
3120 ("Source".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), "foo".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()),
3121 ("Maintainer".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), "Foo Bar <[email protected]>".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()),
3122 ]
3123 );
3124 }
3125
3126 fn rebuild_valuerust-analyzer cargo deb822-lossless 0.5.18 lossless/rebuild_value().(
3127 builder: &mut GreenNodeBuilderrust-analyzer cargo rowan 0.16.1 green/builder/GreenNodeBuilder#,
3128 mut tokens: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<(SyntaxKindrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#, Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#)>,
3129 key_len: usize,
3130 indentation: u32,
3131 immediate_empty_line: bool,
3132 max_line_length_one_liner: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<usize>,
3133 ) {
3134 let first_line_len = tokens
3135 .iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().()
3136 .take_whilerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#take_while().(|(k, _t)| *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().k 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().NEWLINErust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#NEWLINE#)
3137 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|(_k, t)| t.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]len().())
3138 .sumrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#sum().::<usize>() 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().key_len 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().2 /* ": " */;
3139
3140 let has_newline = tokens.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().anyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]any().(|(k, _t)| *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().k rust-analyzer cargo deb822-lossless 0.5.18 lex/impl#[SyntaxKind][`PartialEq<Self>`]eq().==rust-analyzer cargo deb822-lossless 0.5.18 lex/impl#[SyntaxKind][`PartialEq<Self>`]eq(). rust-analyzer cargo deb822-lossless 0.5.18 lex/impl#[SyntaxKind][`PartialEq<Self>`]eq().NEWLINErust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#NEWLINE#);
3141
3142 let mut last_was_newline = false;
3143 if max_line_length_one_liner
3144 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|mll| first_line_len rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le().<=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le().mll)
3145 .unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().(false)
3146 && !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().has_newline
3147 {
3148 // Just copy tokens if the value fits into one line
3149 for (k, t) in tokens {
3150 builder.tokenrust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]token().(k.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), &t);
3151 }
3152 } else {
3153 // Insert a leading newline if the value is multi-line and immediate_empty_line is set
3154 if immediate_empty_line && has_newline {
3155 builder.tokenrust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]token().(NEWLINErust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#NEWLINE#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), "\n");
3156 last_was_newline = true;
3157 } else {
3158 builder.tokenrust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]token().(WHITESPACErust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#WHITESPACE#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), " ");
3159 }
3160 // Strip leading whitespace and newlines
3161 let mut start_idx = 0;
3162 while start_idx 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().tokens.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().() {
3163 if tokens[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().start_idx]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()..0 rust-analyzer cargo deb822-lossless 0.5.18 lex/impl#[SyntaxKind][`PartialEq<Self>`]eq().==rust-analyzer cargo deb822-lossless 0.5.18 lex/impl#[SyntaxKind][`PartialEq<Self>`]eq(). rust-analyzer cargo deb822-lossless 0.5.18 lex/impl#[SyntaxKind][`PartialEq<Self>`]eq().NEWLINErust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#NEWLINE# || tokens[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().start_idx]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()..0 rust-analyzer cargo deb822-lossless 0.5.18 lex/impl#[SyntaxKind][`PartialEq<Self>`]eq().==rust-analyzer cargo deb822-lossless 0.5.18 lex/impl#[SyntaxKind][`PartialEq<Self>`]eq(). rust-analyzer cargo deb822-lossless 0.5.18 lex/impl#[SyntaxKind][`PartialEq<Self>`]eq().WHITESPACErust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#WHITESPACE# {
3164 start_idx rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().1;
3165 } else {
3166 break;
3167 }
3168 }
3169 tokens.drainrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]drain().(..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeTo#start_idx);
3170 // Pre-allocate indentation string to avoid repeated allocations
3171 let indent_str = " ".repeatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]repeat().(indentation as usize);
3172 for (k, t) in tokens {
3173 if last_was_newline {
3174 builder.tokenrust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]token().(INDENTrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#INDENT#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), &indent_str);
3175 }
3176 builder.tokenrust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]token().(k.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), &t);
3177 last_was_newline = k rust-analyzer cargo deb822-lossless 0.5.18 lex/impl#[SyntaxKind][`PartialEq<Self>`]eq().==rust-analyzer cargo deb822-lossless 0.5.18 lex/impl#[SyntaxKind][`PartialEq<Self>`]eq(). rust-analyzer cargo deb822-lossless 0.5.18 lex/impl#[SyntaxKind][`PartialEq<Self>`]eq().NEWLINErust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#NEWLINE#;
3178 }
3179 }
3180
3181 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().last_was_newline {
3182 builder.tokenrust-analyzer cargo rowan 0.16.1 green/builder/impl#[`GreenNodeBuilder<'_>`]token().(NEWLINErust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#NEWLINE#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), "\n");
3183 }
3184 }
3185
3186 #[cfg(test)]
3187 mod testsrust-analyzer cargo deb822-lossless 0.5.18 lossless/tests/ {
3188 use superrust-analyzer cargo deb822-lossless 0.5.18 lossless/::*;
3189 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
3190 fn test_parserust-analyzer cargo deb822-lossless 0.5.18 lossless/tests/test_parse().() {
3191 let d: superrust-analyzer cargo deb822-lossless 0.5.18 lossless/::Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822# = r#"Source: foo
3192 Maintainer: Foo Bar <[email protected]>
3193 Section: net
3194
3195 Package: foo
3196 Architecture: all
3197 Depends: libc6
3198 Description: This is a description
3199 With details
3200 "#
3201 .parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().()
3202 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
3203 let mut ps = d.paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraphs().();
3204 let p = ps.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().();
3205
3206 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(p.getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("Source").as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("foo"));
3207 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
3208 p.getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("Maintainer").as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(),
3209 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("Foo Bar <[email protected]>")
3210 );
3211 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(p.getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("Section").as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("net"));
3212
3213 let b = ps.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().();
3214 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(b.getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("Package").as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("foo"));
3215 }
3216
3217 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
3218 fn test_after_multi_linerust-analyzer cargo deb822-lossless 0.5.18 lossless/tests/test_after_multi_line().() {
3219 let d: superrust-analyzer cargo deb822-lossless 0.5.18 lossless/::Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822# = r#"Source: golang-github-blah-blah
3220 Section: devel
3221 Priority: optional
3222 Standards-Version: 4.2.0
3223 Maintainer: Some Maintainer <[email protected]>
3224 Build-Depends: debhelper (>= 11~),
3225 dh-golang,
3226 golang-any
3227 Homepage: https://github.com/j-keck/arping
3228 "#
3229 .parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().()
3230 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
3231 let mut ps = d.paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraphs().();
3232 let p = ps.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().();
3233 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(p.getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("Source").as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("golang-github-blah-blah"));
3234 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(p.getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("Section").as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("devel"));
3235 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(p.getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("Priority").as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("optional"));
3236 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(p.getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("Standards-Version").as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("4.2.0"));
3237 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
3238 p.getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("Maintainer").as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(),
3239 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("Some Maintainer <[email protected]>")
3240 );
3241 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
3242 p.getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("Build-Depends").as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(),
3243 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("debhelper (>= 11~),\ndh-golang,\ngolang-any")
3244 );
3245 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
3246 p.getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("Homepage").as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(),
3247 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("https://github.com/j-keck/arping")
3248 );
3249 }
3250
3251 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
3252 fn test_remove_fieldrust-analyzer cargo deb822-lossless 0.5.18 lossless/tests/test_remove_field().() {
3253 let d: superrust-analyzer cargo deb822-lossless 0.5.18 lossless/::Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822# = r#"Source: foo
3254 # Comment
3255 Maintainer: Foo Bar <[email protected]>
3256 Section: net
3257
3258 Package: foo
3259 Architecture: all
3260 Depends: libc6
3261 Description: This is a description
3262 With details
3263 "#
3264 .parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().()
3265 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
3266 let mut ps = d.paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraphs().();
3267 let mut p = ps.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().();
3268 p.setrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]set().("Foo", "Bar");
3269 p.removerust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]remove().("Section");
3270 p.removerust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]remove().("Nonexistent");
3271 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(p.getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("Foo").as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("Bar"));
3272 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
3273 p.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(),
3274 r#"Source: foo
3275 # Comment
3276 Maintainer: Foo Bar <[email protected]>
3277 Foo: Bar
3278 "#
3279 );
3280 }
3281
3282 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
3283 fn test_rename_fieldrust-analyzer cargo deb822-lossless 0.5.18 lossless/tests/test_rename_field().() {
3284 let d: superrust-analyzer cargo deb822-lossless 0.5.18 lossless/::Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822# = r#"Source: foo
3285 Vcs-Browser: https://salsa.debian.org/debian/foo
3286 "#
3287 .parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().()
3288 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
3289 let mut ps = d.paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraphs().();
3290 let mut p = ps.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().();
3291 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(p.renamerust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]rename().("Vcs-Browser", "Homepage"));
3292 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
3293 p.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(),
3294 r#"Source: foo
3295 Homepage: https://salsa.debian.org/debian/foo
3296 "#
3297 );
3298
3299 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
3300 p.getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("Homepage").as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(),
3301 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("https://salsa.debian.org/debian/foo")
3302 );
3303 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(p.getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("Vcs-Browser").as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
3304
3305 // Nonexistent field
3306 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().p.renamerust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]rename().("Nonexistent", "Homepage"));
3307 }
3308
3309 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
3310 fn test_set_fieldrust-analyzer cargo deb822-lossless 0.5.18 lossless/tests/test_set_field().() {
3311 let d: superrust-analyzer cargo deb822-lossless 0.5.18 lossless/::Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822# = r#"Source: foo
3312 Maintainer: Foo Bar <[email protected]>
3313 "#
3314 .parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().()
3315 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
3316 let mut ps = d.paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraphs().();
3317 let mut p = ps.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().();
3318 p.setrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]set().("Maintainer", "Somebody Else <[email protected]>");
3319 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
3320 p.getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("Maintainer").as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(),
3321 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("Somebody Else <[email protected]>")
3322 );
3323 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
3324 p.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(),
3325 r#"Source: foo
3326 Maintainer: Somebody Else <[email protected]>
3327 "#
3328 );
3329 }
3330
3331 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
3332 fn test_set_new_fieldrust-analyzer cargo deb822-lossless 0.5.18 lossless/tests/test_set_new_field().() {
3333 let d: superrust-analyzer cargo deb822-lossless 0.5.18 lossless/::Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822# = r#"Source: foo
3334 "#
3335 .parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().()
3336 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
3337 let mut ps = d.paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraphs().();
3338 let mut p = ps.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().();
3339 p.setrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]set().("Maintainer", "Somebody <[email protected]>");
3340 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
3341 p.getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("Maintainer").as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(),
3342 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("Somebody <[email protected]>")
3343 );
3344 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
3345 p.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(),
3346 r#"Source: foo
3347 Maintainer: Somebody <[email protected]>
3348 "#
3349 );
3350 }
3351
3352 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
3353 fn test_add_paragraphrust-analyzer cargo deb822-lossless 0.5.18 lossless/tests/test_add_paragraph().() {
3354 let mut d = superrust-analyzer cargo deb822-lossless 0.5.18 lossless/::Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#::newrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]new().();
3355 let mut p = d.add_paragraphrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]add_paragraph().();
3356 p.setrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]set().("Foo", "Bar");
3357 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(p.getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("Foo").as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("Bar"));
3358 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
3359 p.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(),
3360 r#"Foo: Bar
3361 "#
3362 );
3363 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
3364 d.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(),
3365 r#"Foo: Bar
3366 "#
3367 );
3368
3369 let mut p = d.add_paragraphrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]add_paragraph().();
3370 p.setrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]set().("Foo", "Blah");
3371 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(p.getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("Foo").as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("Blah"));
3372 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
3373 d.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(),
3374 r#"Foo: Bar
3375
3376 Foo: Blah
3377 "#
3378 );
3379 }
3380
3381 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
3382 fn test_crud_paragraphrust-analyzer cargo deb822-lossless 0.5.18 lossless/tests/test_crud_paragraph().() {
3383 let mut d = superrust-analyzer cargo deb822-lossless 0.5.18 lossless/::Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#::newrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]new().();
3384 let mut p = d.insert_paragraphrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]insert_paragraph().(0);
3385 p.setrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]set().("Foo", "Bar");
3386 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(p.getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("Foo").as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("Bar"));
3387 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
3388 d.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(),
3389 r#"Foo: Bar
3390 "#
3391 );
3392
3393 // test prepend
3394 let mut p = d.insert_paragraphrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]insert_paragraph().(0);
3395 p.setrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]set().("Foo", "Blah");
3396 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(p.getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("Foo").as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("Blah"));
3397 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
3398 d.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(),
3399 r#"Foo: Blah
3400
3401 Foo: Bar
3402 "#
3403 );
3404
3405 // test delete
3406 d.remove_paragraphrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]remove_paragraph().(1);
3407 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(d.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "Foo: Blah\n\n");
3408
3409 // test update again
3410 p.setrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]set().("Foo", "Baz");
3411 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(d.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "Foo: Baz\n\n");
3412
3413 // test delete again
3414 d.remove_paragraphrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]remove_paragraph().(0);
3415 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(d.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "");
3416 }
3417
3418 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
3419 fn test_swap_paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/tests/test_swap_paragraphs().() {
3420 // Test basic swap
3421 let mut d: superrust-analyzer cargo deb822-lossless 0.5.18 lossless/::Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822# = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![
3422 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![("Foo", "Bar")].into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(),
3423 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![("A", "B")].into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(),
3424 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![("X", "Y")].into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(),
3425 ]
3426 .into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().()
3427 .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().();
3428
3429 d.swap_paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]swap_paragraphs().(0, 2);
3430 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(d.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "X: Y\n\nA: B\n\nFoo: Bar\n");
3431
3432 // Swap back
3433 d.swap_paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]swap_paragraphs().(0, 2);
3434 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(d.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "Foo: Bar\n\nA: B\n\nX: Y\n");
3435
3436 // Swap adjacent paragraphs
3437 d.swap_paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]swap_paragraphs().(0, 1);
3438 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(d.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "A: B\n\nFoo: Bar\n\nX: Y\n");
3439
3440 // Swap with same index should be no-op
3441 let before = d.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().();
3442 d.swap_paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]swap_paragraphs().(1, 1);
3443 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(d.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), before);
3444 }
3445
3446 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
3447 fn test_swap_paragraphs_preserves_contentrust-analyzer cargo deb822-lossless 0.5.18 lossless/tests/test_swap_paragraphs_preserves_content().() {
3448 // Test that field content is preserved
3449 let mut d: superrust-analyzer cargo deb822-lossless 0.5.18 lossless/::Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822# = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![
3450 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![("Field1", "Value1"), ("Field2", "Value2")]
3451 .into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().()
3452 .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(),
3453 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![("FieldA", "ValueA"), ("FieldB", "ValueB")]
3454 .into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().()
3455 .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(),
3456 ]
3457 .into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().()
3458 .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().();
3459
3460 d.swap_paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]swap_paragraphs().(0, 1);
3461
3462 let mut paras = d.paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraphs().();
3463 let p1 = paras.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().();
3464 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(p1.getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("FieldA").as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("ValueA"));
3465 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(p1.getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("FieldB").as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("ValueB"));
3466
3467 let p2 = paras.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().();
3468 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(p2.getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("Field1").as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("Value1"));
3469 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(p2.getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("Field2").as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("Value2"));
3470 }
3471
3472 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
3473 #[should_panic(expected = "out of bounds")]
3474 fn test_swap_paragraphs_out_of_boundsrust-analyzer cargo deb822-lossless 0.5.18 lossless/tests/test_swap_paragraphs_out_of_bounds().() {
3475 let mut d: superrust-analyzer cargo deb822-lossless 0.5.18 lossless/::Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822# = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![
3476 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![("Foo", "Bar")].into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(),
3477 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![("A", "B")].into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(),
3478 ]
3479 .into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().()
3480 .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().();
3481
3482 d.swap_paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]swap_paragraphs().(0, 5);
3483 }
3484
3485 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
3486 fn test_multiline_entryrust-analyzer cargo deb822-lossless 0.5.18 lossless/tests/test_multiline_entry().() {
3487 use superrust-analyzer cargo deb822-lossless 0.5.18 lossless/::SyntaxKindrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#::*;
3488 use rowanrust-analyzer cargo rowan 0.16.1 crate/::astrust-analyzer cargo rowan 0.16.1 ast/::AstNoderust-analyzer cargo rowan 0.16.1 ast/AstNode#;
3489
3490 let entry = superrust-analyzer cargo deb822-lossless 0.5.18 lossless/::Entryrust-analyzer cargo deb822-lossless 0.5.18 lossless/Entry#::newrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]new().("foo", "bar\nbaz");
3491 let tokens: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_> = entry
3492 .syntaxrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry][AstNode]syntax().()
3493 .descendants_with_tokensrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxNode<L>`]descendants_with_tokens().()
3494 .filter_maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#filter_map().(|tok| tok.into_tokenrust-analyzer cargo rowan 0.16.1 utility_types/impl#[`NodeOrToken<N, T>`]into_token().())
3495 .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().();
3496
3497 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!("foo: bar\n baz\n", entry.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().());
3498 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!("bar\nbaz", entry.valuerust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]value().());
3499
3500 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
3501 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![
3502 (KEYrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#KEY#, "foo"),
3503 (COLONrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#COLON#, ":"),
3504 (WHITESPACErust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#WHITESPACE#, " "),
3505 (VALUErust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#VALUE#, "bar"),
3506 (NEWLINErust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#NEWLINE#, "\n"),
3507 (INDENTrust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#INDENT#, " "),
3508 (VALUErust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#VALUE#, "baz"),
3509 (NEWLINErust-analyzer cargo deb822-lossless 0.5.18 lex/SyntaxKind#NEWLINE#, "\n"),
3510 ],
3511 tokens
3512 .iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().()
3513 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|token| (token.kindrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxToken<L>`]kind().(), token.textrust-analyzer cargo rowan 0.16.1 api/impl#[`SyntaxToken<L>`]text().()))
3514 .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#<_>>()
3515 );
3516 }
3517
3518 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
3519 fn test_apt_entryrust-analyzer cargo deb822-lossless 0.5.18 lossless/tests/test_apt_entry().() {
3520 let text = r#"Package: cvsd
3521 Binary: cvsd
3522 Version: 1.0.24
3523 Maintainer: Arthur de Jong <[email protected]>
3524 Build-Depends: debhelper (>= 9), po-debconf
3525 Architecture: any
3526 Standards-Version: 3.9.3
3527 Format: 3.0 (native)
3528 Files:
3529 b7a7d67a02974c52c408fdb5e118406d 890 cvsd_1.0.24.dsc
3530 b73ee40774c3086cb8490cdbb96ac883 258139 cvsd_1.0.24.tar.gz
3531 Vcs-Browser: http://arthurdejong.org/viewvc/cvsd/
3532 Vcs-Cvs: :pserver:[email protected]:/arthur/
3533 Checksums-Sha256:
3534 a7bb7a3aacee19cd14ce5c26cb86e348b1608e6f1f6e97c6ea7c58efa440ac43 890 cvsd_1.0.24.dsc
3535 46bc517760c1070ae408693b89603986b53e6f068ae6bdc744e2e830e46b8cba 258139 cvsd_1.0.24.tar.gz
3536 Homepage: http://arthurdejong.org/cvsd/
3537 Package-List:
3538 cvsd deb vcs optional
3539 Directory: pool/main/c/cvsd
3540 Priority: source
3541 Section: vcs
3542
3543 "#;
3544 let d: superrust-analyzer cargo deb822-lossless 0.5.18 lossless/::Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822# = text.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().();
3545 let p = d.paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraphs().().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().();
3546 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(p.getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("Binary").as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("cvsd"));
3547 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(p.getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("Version").as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("1.0.24"));
3548 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
3549 p.getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("Maintainer").as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(),
3550 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("Arthur de Jong <[email protected]>")
3551 );
3552 }
3553
3554 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
3555 fn test_formatrust-analyzer cargo deb822-lossless 0.5.18 lossless/tests/test_format().() {
3556 let d: superrust-analyzer cargo deb822-lossless 0.5.18 lossless/::Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822# = r#"Source: foo
3557 Maintainer: Foo Bar <[email protected]>
3558 Section: net
3559 Blah: blah # comment
3560 Multi-Line:
3561 Ahoi!
3562 Matey!
3563
3564 "#
3565 .parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().()
3566 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
3567 let mut ps = d.paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraphs().();
3568 let p = ps.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().();
3569 let result = p.wrap_and_sortrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]wrap_and_sort().(
3570 craterust-analyzer cargo deb822-lossless 0.5.18 crate/::Indentationrust-analyzer cargo deb822-lossless 0.5.18 Indentation#::FieldNameLengthrust-analyzer cargo deb822-lossless 0.5.18 Indentation#FieldNameLength#,
3571 false,
3572 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
3573 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#::<&dyn Fnrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/function/Fn#(&superrust-analyzer cargo deb822-lossless 0.5.18 lossless/::Entryrust-analyzer cargo deb822-lossless 0.5.18 lossless/Entry#, &superrust-analyzer cargo deb822-lossless 0.5.18 lossless/::Entryrust-analyzer cargo deb822-lossless 0.5.18 lossless/Entry#) -> 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#>,
3574 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
3575 );
3576 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
3577 result.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(),
3578 r#"Source: foo
3579 Maintainer: Foo Bar <[email protected]>
3580 Section: net
3581 Blah: blah # comment
3582 Multi-Line: Ahoi!
3583 Matey!
3584 "#
3585 );
3586 }
3587
3588 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
3589 fn test_format_sort_paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/tests/test_format_sort_paragraphs().() {
3590 let d: superrust-analyzer cargo deb822-lossless 0.5.18 lossless/::Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822# = r#"Source: foo
3591 Maintainer: Foo Bar <[email protected]>
3592
3593 # This is a comment
3594 Source: bar
3595 Maintainer: Bar Foo <[email protected]>
3596
3597 "#
3598 .parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().()
3599 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
3600 let result = d.wrap_and_sortrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]wrap_and_sort().(
3601 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&|a: &superrust-analyzer cargo deb822-lossless 0.5.18 lossless/::Paragraphrust-analyzer cargo deb822-lossless 0.5.18 lossless/Paragraph#, b: &superrust-analyzer cargo deb822-lossless 0.5.18 lossless/::Paragraphrust-analyzer cargo deb822-lossless 0.5.18 lossless/Paragraph#| {
3602 a.getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("Source").cmprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Ord]cmp().(&b.getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("Source"))
3603 }),
3604 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&|p| {
3605 p.wrap_and_sortrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]wrap_and_sort().(
3606 craterust-analyzer cargo deb822-lossless 0.5.18 crate/::Indentationrust-analyzer cargo deb822-lossless 0.5.18 Indentation#::FieldNameLengthrust-analyzer cargo deb822-lossless 0.5.18 Indentation#FieldNameLength#,
3607 false,
3608 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
3609 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#::<&dyn Fnrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/function/Fn#(&superrust-analyzer cargo deb822-lossless 0.5.18 lossless/::Entryrust-analyzer cargo deb822-lossless 0.5.18 lossless/Entry#, &superrust-analyzer cargo deb822-lossless 0.5.18 lossless/::Entryrust-analyzer cargo deb822-lossless 0.5.18 lossless/Entry#) -> 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#>,
3610 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
3611 )
3612 }),
3613 );
3614 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
3615 result.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(),
3616 r#"# This is a comment
3617 Source: bar
3618 Maintainer: Bar Foo <[email protected]>
3619
3620 Source: foo
3621 Maintainer: Foo Bar <[email protected]>
3622 "#,
3623 );
3624 }
3625
3626 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
3627 fn test_format_sort_fieldsrust-analyzer cargo deb822-lossless 0.5.18 lossless/tests/test_format_sort_fields().() {
3628 let d: superrust-analyzer cargo deb822-lossless 0.5.18 lossless/::Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822# = r#"Source: foo
3629 Maintainer: Foo Bar <[email protected]>
3630 Build-Depends: debhelper (>= 9), po-debconf
3631 Homepage: https://example.com/
3632
3633 "#
3634 .parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().()
3635 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
3636 let result = d.wrap_and_sortrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]wrap_and_sort().(
3637 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
3638 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&|p: &superrust-analyzer cargo deb822-lossless 0.5.18 lossless/::Paragraphrust-analyzer cargo deb822-lossless 0.5.18 lossless/Paragraph#| -> superrust-analyzer cargo deb822-lossless 0.5.18 lossless/::Paragraphrust-analyzer cargo deb822-lossless 0.5.18 lossless/Paragraph# {
3639 p.wrap_and_sortrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]wrap_and_sort().(
3640 craterust-analyzer cargo deb822-lossless 0.5.18 crate/::Indentationrust-analyzer cargo deb822-lossless 0.5.18 Indentation#::FieldNameLengthrust-analyzer cargo deb822-lossless 0.5.18 Indentation#FieldNameLength#,
3641 false,
3642 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
3643 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&|a: &superrust-analyzer cargo deb822-lossless 0.5.18 lossless/::Entryrust-analyzer cargo deb822-lossless 0.5.18 lossless/Entry#, b: &superrust-analyzer cargo deb822-lossless 0.5.18 lossless/::Entryrust-analyzer cargo deb822-lossless 0.5.18 lossless/Entry#| a.keyrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]key().().cmprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Ord]cmp().(&b.keyrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]key().())),
3644 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
3645 )
3646 }),
3647 );
3648 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
3649 result.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(),
3650 r#"Build-Depends: debhelper (>= 9), po-debconf
3651 Homepage: https://example.com/
3652 Maintainer: Foo Bar <[email protected]>
3653 Source: foo
3654 "#
3655 );
3656 }
3657
3658 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
3659 fn test_para_from_iterrust-analyzer cargo deb822-lossless 0.5.18 lossless/tests/test_para_from_iter().() {
3660 let p: superrust-analyzer cargo deb822-lossless 0.5.18 lossless/::Paragraphrust-analyzer cargo deb822-lossless 0.5.18 lossless/Paragraph# = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![("Foo", "Bar"), ("Baz", "Qux")].into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().();
3661 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
3662 p.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(),
3663 r#"Foo: Bar
3664 Baz: Qux
3665 "#
3666 );
3667
3668 let p: superrust-analyzer cargo deb822-lossless 0.5.18 lossless/::Paragraphrust-analyzer cargo deb822-lossless 0.5.18 lossless/Paragraph# = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![
3669 ("Foo".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "Bar".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()),
3670 ("Baz".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "Qux".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()),
3671 ]
3672 .into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().()
3673 .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().();
3674
3675 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
3676 p.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(),
3677 r#"Foo: Bar
3678 Baz: Qux
3679 "#
3680 );
3681 }
3682
3683 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
3684 fn test_deb822_from_iterrust-analyzer cargo deb822-lossless 0.5.18 lossless/tests/test_deb822_from_iter().() {
3685 let d: superrust-analyzer cargo deb822-lossless 0.5.18 lossless/::Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822# = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![
3686 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![("Foo", "Bar"), ("Baz", "Qux")].into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(),
3687 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![("A", "B"), ("C", "D")].into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(),
3688 ]
3689 .into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().()
3690 .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().();
3691 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
3692 d.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(),
3693 r#"Foo: Bar
3694 Baz: Qux
3695
3696 A: B
3697 C: D
3698 "#
3699 );
3700 }
3701
3702 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
3703 fn test_format_parse_errorrust-analyzer cargo deb822-lossless 0.5.18 lossless/tests/test_format_parse_error().() {
3704 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(ParseErrorrust-analyzer cargo deb822-lossless 0.5.18 lossless/ParseError#(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!!["foo".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()]).to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "foo\n");
3705 }
3706
3707 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
3708 fn test_set_with_field_orderrust-analyzer cargo deb822-lossless 0.5.18 lossless/tests/test_set_with_field_order().() {
3709 let mut p = superrust-analyzer cargo deb822-lossless 0.5.18 lossless/::Paragraphrust-analyzer cargo deb822-lossless 0.5.18 lossless/Paragraph#::newrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]new().();
3710 let custom_order = &["Foo", "Bar", "Baz"];
3711
3712 p.set_with_field_orderrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]set_with_field_order().("Baz", "3", custom_order);
3713 p.set_with_field_orderrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]set_with_field_order().("Foo", "1", custom_order);
3714 p.set_with_field_orderrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]set_with_field_order().("Bar", "2", custom_order);
3715 p.set_with_field_orderrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]set_with_field_order().("Unknown", "4", custom_order);
3716
3717 let keys: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_> = p.keysrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]keys().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().();
3718 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(keys[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()., "Foo");
3719 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(keys[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().1]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()., "Bar");
3720 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(keys[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().2]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()., "Baz");
3721 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(keys[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().3]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()., "Unknown");
3722 }
3723
3724 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
3725 fn test_positioned_parse_errorrust-analyzer cargo deb822-lossless 0.5.18 lossless/tests/test_positioned_parse_error().() {
3726 let error = PositionedParseErrorrust-analyzer cargo deb822-lossless 0.5.18 lossless/PositionedParseError# {
3727 messagerust-analyzer cargo deb822-lossless 0.5.18 lossless/PositionedParseError#message.: "test error".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(),
3728 rangerust-analyzer cargo deb822-lossless 0.5.18 lossless/PositionedParseError#range.: rowanrust-analyzer cargo rowan 0.16.1 crate/::TextRangerust-analyzer cargo text-size 1.1.1 range/TextRange#::newrust-analyzer cargo text-size 1.1.1 range/impl#[TextRange]new().(rowanrust-analyzer cargo rowan 0.16.1 crate/::TextSizerust-analyzer cargo text-size 1.1.1 size/TextSize#::fromrust-analyzer cargo text-size 1.1.1 size/impl#[TextSize][`From<u32>`]from().(5), rowanrust-analyzer cargo rowan 0.16.1 crate/::TextSizerust-analyzer cargo text-size 1.1.1 size/TextSize#::fromrust-analyzer cargo text-size 1.1.1 size/impl#[TextSize][`From<u32>`]from().(10)),
3729 coderust-analyzer cargo deb822-lossless 0.5.18 lossless/PositionedParseError#code.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("test_code".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()),
3730 };
3731 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(error.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "test error");
3732 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(error.rangerust-analyzer cargo deb822-lossless 0.5.18 lossless/PositionedParseError#range..startrust-analyzer cargo text-size 1.1.1 range/impl#[TextRange]start().(), rowanrust-analyzer cargo rowan 0.16.1 crate/::TextSizerust-analyzer cargo text-size 1.1.1 size/TextSize#::fromrust-analyzer cargo text-size 1.1.1 size/impl#[TextSize][`From<u32>`]from().(5));
3733 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(error.rangerust-analyzer cargo deb822-lossless 0.5.18 lossless/PositionedParseError#range..endrust-analyzer cargo text-size 1.1.1 range/impl#[TextRange]end().(), rowanrust-analyzer cargo rowan 0.16.1 crate/::TextSizerust-analyzer cargo text-size 1.1.1 size/TextSize#::fromrust-analyzer cargo text-size 1.1.1 size/impl#[TextSize][`From<u32>`]from().(10));
3734 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(error.coderust-analyzer cargo deb822-lossless 0.5.18 lossless/PositionedParseError#code., Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("test_code".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()));
3735 }
3736
3737 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
3738 fn test_format_errorrust-analyzer cargo deb822-lossless 0.5.18 lossless/tests/test_format_error().() {
3739 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
3740 superrust-analyzer cargo deb822-lossless 0.5.18 lossless/::Errorrust-analyzer cargo deb822-lossless 0.5.18 lossless/Error#::ParseErrorrust-analyzer cargo deb822-lossless 0.5.18 lossless/Error#ParseError#(ParseErrorrust-analyzer cargo deb822-lossless 0.5.18 lossless/ParseError#(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!!["foo".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()])).to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(),
3741 "foo\n"
3742 );
3743 }
3744
3745 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
3746 fn test_get_allrust-analyzer cargo deb822-lossless 0.5.18 lossless/tests/test_get_all().() {
3747 let d: superrust-analyzer cargo deb822-lossless 0.5.18 lossless/::Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822# = r#"Source: foo
3748 Maintainer: Foo Bar <[email protected]>
3749 Maintainer: Bar Foo <[email protected]>"#
3750 .parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().()
3751 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
3752 let p = d.paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraphs().().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().();
3753 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
3754 p.get_allrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get_all().("Maintainer").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#<_>>(),
3755 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!!["Foo Bar <[email protected]>", "Bar Foo <[email protected]>"]
3756 );
3757 }
3758
3759 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
3760 fn test_get_with_indent_single_linerust-analyzer cargo deb822-lossless 0.5.18 lossless/tests/test_get_with_indent_single_line().() {
3761 let input = "Field: single line value\n";
3762 let deb = superrust-analyzer cargo deb822-lossless 0.5.18 lossless/::Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#::from_strrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822][FromStr]from_str().(input).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
3763 let para = deb.paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraphs().().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().();
3764
3765 // Single-line values should be unchanged regardless of indent pattern
3766 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
3767 para.get_with_indentrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get_with_indent().("Field", &superrust-analyzer cargo deb822-lossless 0.5.18 lossless/::IndentPatternrust-analyzer cargo deb822-lossless 0.5.18 lossless/IndentPattern#::Fixedrust-analyzer cargo deb822-lossless 0.5.18 lossless/IndentPattern#Fixed#(2)),
3768 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("single line value".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())
3769 );
3770 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
3771 para.get_with_indentrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get_with_indent().("Field", &superrust-analyzer cargo deb822-lossless 0.5.18 lossless/::IndentPatternrust-analyzer cargo deb822-lossless 0.5.18 lossless/IndentPattern#::FieldNameLengthrust-analyzer cargo deb822-lossless 0.5.18 lossless/IndentPattern#FieldNameLength#),
3772 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("single line value".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())
3773 );
3774 }
3775
3776 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
3777 fn test_get_with_indent_fixedrust-analyzer cargo deb822-lossless 0.5.18 lossless/tests/test_get_with_indent_fixed().() {
3778 let input = "Field: First\n Second\n Third\n";
3779 let deb = superrust-analyzer cargo deb822-lossless 0.5.18 lossless/::Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#::from_strrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822][FromStr]from_str().(input).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
3780 let para = deb.paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraphs().().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().();
3781
3782 // Get with fixed 2-space indentation - strips 2 spaces, leaves 1
3783 let value = para
3784 .get_with_indentrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get_with_indent().("Field", &superrust-analyzer cargo deb822-lossless 0.5.18 lossless/::IndentPatternrust-analyzer cargo deb822-lossless 0.5.18 lossless/IndentPattern#::Fixedrust-analyzer cargo deb822-lossless 0.5.18 lossless/IndentPattern#Fixed#(2))
3785 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().();
3786 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(value, "First\n Second\n Third");
3787
3788 // Get with fixed 1-space indentation - strips 1 space, leaves 2
3789 let value = para
3790 .get_with_indentrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get_with_indent().("Field", &superrust-analyzer cargo deb822-lossless 0.5.18 lossless/::IndentPatternrust-analyzer cargo deb822-lossless 0.5.18 lossless/IndentPattern#::Fixedrust-analyzer cargo deb822-lossless 0.5.18 lossless/IndentPattern#Fixed#(1))
3791 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().();
3792 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(value, "First\n Second\n Third");
3793
3794 // Get with fixed 3-space indentation - strips all 3 spaces
3795 let value = para
3796 .get_with_indentrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get_with_indent().("Field", &superrust-analyzer cargo deb822-lossless 0.5.18 lossless/::IndentPatternrust-analyzer cargo deb822-lossless 0.5.18 lossless/IndentPattern#::Fixedrust-analyzer cargo deb822-lossless 0.5.18 lossless/IndentPattern#Fixed#(3))
3797 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().();
3798 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(value, "First\nSecond\nThird");
3799 }
3800
3801 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
3802 fn test_get_with_indent_field_name_lengthrust-analyzer cargo deb822-lossless 0.5.18 lossless/tests/test_get_with_indent_field_name_length().() {
3803 let input = "Description: First line\n Second line\n Third line\n";
3804 let deb = superrust-analyzer cargo deb822-lossless 0.5.18 lossless/::Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#::from_strrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822][FromStr]from_str().(input).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
3805 let para = deb.paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraphs().().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().();
3806
3807 // Get with FieldNameLength pattern
3808 // "Description: " is 13 characters, so strips 13 spaces, leaves 0
3809 let value = para
3810 .get_with_indentrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get_with_indent().("Description", &superrust-analyzer cargo deb822-lossless 0.5.18 lossless/::IndentPatternrust-analyzer cargo deb822-lossless 0.5.18 lossless/IndentPattern#::FieldNameLengthrust-analyzer cargo deb822-lossless 0.5.18 lossless/IndentPattern#FieldNameLength#)
3811 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().();
3812 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(value, "First line\nSecond line\nThird line");
3813
3814 // Get with fixed 2-space indentation - strips 2, leaves 11
3815 let value = para
3816 .get_with_indentrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get_with_indent().("Description", &superrust-analyzer cargo deb822-lossless 0.5.18 lossless/::IndentPatternrust-analyzer cargo deb822-lossless 0.5.18 lossless/IndentPattern#::Fixedrust-analyzer cargo deb822-lossless 0.5.18 lossless/IndentPattern#Fixed#(2))
3817 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().();
3818 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
3819 value,
3820 "First line\n Second line\n Third line"
3821 );
3822 }
3823
3824 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
3825 fn test_get_with_indent_nonexistentrust-analyzer cargo deb822-lossless 0.5.18 lossless/tests/test_get_with_indent_nonexistent().() {
3826 let input = "Field: value\n";
3827 let deb = superrust-analyzer cargo deb822-lossless 0.5.18 lossless/::Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#::from_strrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822][FromStr]from_str().(input).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
3828 let para = deb.paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraphs().().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().();
3829
3830 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
3831 para.get_with_indentrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get_with_indent().("NonExistent", &superrust-analyzer cargo deb822-lossless 0.5.18 lossless/::IndentPatternrust-analyzer cargo deb822-lossless 0.5.18 lossless/IndentPattern#::Fixedrust-analyzer cargo deb822-lossless 0.5.18 lossless/IndentPattern#Fixed#(2)),
3832 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#
3833 );
3834 }
3835
3836 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
3837 fn test_get_entryrust-analyzer cargo deb822-lossless 0.5.18 lossless/tests/test_get_entry().() {
3838 let input = r#"Package: test-package
3839 Maintainer: Test User <[email protected]>
3840 Description: A simple test package
3841 with multiple lines
3842 "#;
3843 let deb = superrust-analyzer cargo deb822-lossless 0.5.18 lossless/::Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#::from_strrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822][FromStr]from_str().(input).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
3844 let para = deb.paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraphs().().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().();
3845
3846 // Test getting existing entry
3847 let entry = para.get_entryrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get_entry().("Package");
3848 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(entry.is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().());
3849 let entry = entry.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().();
3850 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(entry.keyrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]key().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("Package".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()));
3851 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(entry.valuerust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]value().(), "test-package");
3852
3853 // Test case-insensitive lookup
3854 let entry = para.get_entryrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get_entry().("package");
3855 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(entry.is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().());
3856 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(entry.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().valuerust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]value().(), "test-package");
3857
3858 // Test multi-line value
3859 let entry = para.get_entryrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get_entry().("Description");
3860 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(entry.is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().());
3861 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
3862 entry.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().valuerust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]value().(),
3863 "A simple test package\nwith multiple lines"
3864 );
3865
3866 // Test non-existent field
3867 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(para.get_entryrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get_entry().("NonExistent"), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
3868 }
3869
3870 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
3871 fn test_entry_rangesrust-analyzer cargo deb822-lossless 0.5.18 lossless/tests/test_entry_ranges().() {
3872 let input = r#"Package: test-package
3873 Maintainer: Test User <[email protected]>
3874 Description: A simple test package
3875 with multiple lines
3876 of description text"#;
3877
3878 let deb822 = superrust-analyzer cargo deb822-lossless 0.5.18 lossless/::Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#::from_strrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822][FromStr]from_str().(input).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
3879 let paragraph = deb822.paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraphs().().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().();
3880 let entries: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_> = paragraph.entriesrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]entries().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().();
3881
3882 // Test first entry (Package)
3883 let package_entry = &entries[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().;
3884 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(package_entry.keyrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]key().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("Package".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()));
3885
3886 // Test key_range
3887 let key_range = package_entry.key_rangerust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]key_range().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().();
3888 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
3889 &input[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().key_range.startrust-analyzer cargo text-size 1.1.1 range/impl#[TextRange]start().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()..key_range.endrust-analyzer cargo text-size 1.1.1 range/impl#[TextRange]end().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().,
3890 "Package"
3891 );
3892
3893 // Test colon_range
3894 let colon_range = package_entry.colon_rangerust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]colon_range().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().();
3895 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
3896 &input[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().colon_range.startrust-analyzer cargo text-size 1.1.1 range/impl#[TextRange]start().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()..colon_range.endrust-analyzer cargo text-size 1.1.1 range/impl#[TextRange]end().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().,
3897 ":"
3898 );
3899
3900 // Test value_range
3901 let value_range = package_entry.value_rangerust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]value_range().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().();
3902 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
3903 &input[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().value_range.startrust-analyzer cargo text-size 1.1.1 range/impl#[TextRange]start().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()..value_range.endrust-analyzer cargo text-size 1.1.1 range/impl#[TextRange]end().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().,
3904 "test-package"
3905 );
3906
3907 // Test text_range covers the whole entry
3908 let text_range = package_entry.text_rangerust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]text_range().();
3909 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
3910 &input[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().text_range.startrust-analyzer cargo text-size 1.1.1 range/impl#[TextRange]start().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()..text_range.endrust-analyzer cargo text-size 1.1.1 range/impl#[TextRange]end().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().,
3911 "Package: test-package\n"
3912 );
3913
3914 // Test single-line value_line_ranges
3915 let value_lines = package_entry.value_line_rangesrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]value_line_ranges().();
3916 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(value_lines.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 1);
3917 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
3918 &input[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().value_lines[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()..startrust-analyzer cargo text-size 1.1.1 range/impl#[TextRange]start().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()..value_lines[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()..endrust-analyzer cargo text-size 1.1.1 range/impl#[TextRange]end().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().,
3919 "test-package"
3920 );
3921
3922 // Test value_token_range: single-word value covers the whole value.
3923 let token_range = package_entry.value_token_rangerust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]value_token_range().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().();
3924 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
3925 &input[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().token_range.startrust-analyzer cargo text-size 1.1.1 range/impl#[TextRange]start().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()..token_range.endrust-analyzer cargo text-size 1.1.1 range/impl#[TextRange]end().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().,
3926 "test-package"
3927 );
3928 }
3929
3930 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
3931 fn test_value_token_range_multiwordrust-analyzer cargo deb822-lossless 0.5.18 lossless/tests/test_value_token_range_multiword().() {
3932 let input = "License: GPL-2+ with the autoconf exception\n";
3933 let para = Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#::from_strrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822][FromStr]from_str().(input)
3934 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()
3935 .paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraphs().()
3936 .nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/filter_map/impl#[`FilterMap<I, F>`][Iterator]next().()
3937 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().();
3938 let entry = para.entriesrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]entries().().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().();
3939 let token_range = entry.value_token_rangerust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]value_token_range().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().();
3940 // Only the first whitespace-delimited token (the short-name).
3941 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
3942 &input[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().token_range.startrust-analyzer cargo text-size 1.1.1 range/impl#[TextRange]start().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()..token_range.endrust-analyzer cargo text-size 1.1.1 range/impl#[TextRange]end().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().,
3943 "GPL-2+"
3944 );
3945 }
3946
3947 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
3948 fn test_value_token_range_emptyrust-analyzer cargo deb822-lossless 0.5.18 lossless/tests/test_value_token_range_empty().() {
3949 let input = "Description:\n";
3950 let para = Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#::from_strrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822][FromStr]from_str().(input)
3951 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()
3952 .paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraphs().()
3953 .nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/filter_map/impl#[`FilterMap<I, F>`][Iterator]next().()
3954 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().();
3955 let entry = para.entriesrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]entries().().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().();
3956 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(entry.value_token_rangerust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]value_token_range().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
3957 }
3958
3959 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
3960 fn test_multiline_entry_rangesrust-analyzer cargo deb822-lossless 0.5.18 lossless/tests/test_multiline_entry_ranges().() {
3961 let input = r#"Description: Short description
3962 Extended description line 1
3963 Extended description line 2"#;
3964
3965 let deb822 = superrust-analyzer cargo deb822-lossless 0.5.18 lossless/::Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#::from_strrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822][FromStr]from_str().(input).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
3966 let paragraph = deb822.paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraphs().().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().();
3967 let entry = paragraph.entriesrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]entries().().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().();
3968
3969 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(entry.keyrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]key().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("Description".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()));
3970
3971 // Test value_range spans all lines
3972 let value_range = entry.value_rangerust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]value_range().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().();
3973 let full_value = &input[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().value_range.startrust-analyzer cargo text-size 1.1.1 range/impl#[TextRange]start().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#value_range.endrust-analyzer cargo text-size 1.1.1 range/impl#[TextRange]end().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().;
3974 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(full_value.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]contains().("Short description"));
3975 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(full_value.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]contains().("Extended description line 1"));
3976 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(full_value.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]contains().("Extended description line 2"));
3977
3978 // Test value_line_ranges gives individual lines
3979 let value_lines = entry.value_line_rangesrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]value_line_ranges().();
3980 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(value_lines.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 3);
3981
3982 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
3983 &input[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().value_lines[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()..startrust-analyzer cargo text-size 1.1.1 range/impl#[TextRange]start().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()..value_lines[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()..endrust-analyzer cargo text-size 1.1.1 range/impl#[TextRange]end().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().,
3984 "Short description"
3985 );
3986 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
3987 &input[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().value_lines[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().1]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()..startrust-analyzer cargo text-size 1.1.1 range/impl#[TextRange]start().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()..value_lines[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().1]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()..endrust-analyzer cargo text-size 1.1.1 range/impl#[TextRange]end().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().,
3988 "Extended description line 1"
3989 );
3990 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
3991 &input[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().value_lines[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().2]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()..startrust-analyzer cargo text-size 1.1.1 range/impl#[TextRange]start().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()..value_lines[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().2]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()..endrust-analyzer cargo text-size 1.1.1 range/impl#[TextRange]end().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().,
3992 "Extended description line 2"
3993 );
3994 }
3995
3996 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
3997 fn test_entries_public_accessrust-analyzer cargo deb822-lossless 0.5.18 lossless/tests/test_entries_public_access().() {
3998 let input = r#"Package: test
3999 Version: 1.0"#;
4000
4001 let deb822 = superrust-analyzer cargo deb822-lossless 0.5.18 lossless/::Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#::from_strrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822][FromStr]from_str().(input).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
4002 let paragraph = deb822.paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraphs().().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().();
4003
4004 // Test that entries() method is now public
4005 let entries: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_> = paragraph.entriesrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]entries().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().();
4006 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(entries.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 2);
4007 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(entries[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()..keyrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]key().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("Package".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()));
4008 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(entries[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().1]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()..keyrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]key().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("Version".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()));
4009 }
4010
4011 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
4012 fn test_empty_value_rangesrust-analyzer cargo deb822-lossless 0.5.18 lossless/tests/test_empty_value_ranges().() {
4013 let input = r#"EmptyField: "#;
4014
4015 let deb822 = superrust-analyzer cargo deb822-lossless 0.5.18 lossless/::Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#::from_strrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822][FromStr]from_str().(input).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
4016 let paragraph = deb822.paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraphs().().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().();
4017 let entry = paragraph.entriesrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]entries().().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().();
4018
4019 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(entry.keyrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]key().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("EmptyField".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()));
4020
4021 // Empty value should still have ranges
4022 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(entry.key_rangerust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]key_range().().is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().());
4023 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(entry.colon_rangerust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]colon_range().().is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().());
4024
4025 // Empty value might not have value tokens
4026 let value_lines = entry.value_line_rangesrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]value_line_ranges().();
4027 // This depends on how the parser handles empty values
4028 // but we should not panic
4029 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(value_lines.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().() <= 1);
4030 }
4031
4032 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
4033 fn test_range_orderingrust-analyzer cargo deb822-lossless 0.5.18 lossless/tests/test_range_ordering().() {
4034 let input = r#"Field: value"#;
4035
4036 let deb822 = superrust-analyzer cargo deb822-lossless 0.5.18 lossless/::Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#::from_strrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822][FromStr]from_str().(input).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
4037 let paragraph = deb822.paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraphs().().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().();
4038 let entry = paragraph.entriesrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]entries().().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().();
4039
4040 let key_range = entry.key_rangerust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]key_range().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().();
4041 let colon_range = entry.colon_rangerust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]colon_range().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().();
4042 let value_range = entry.value_rangerust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]value_range().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().();
4043 let text_range = entry.text_rangerust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]text_range().();
4044
4045 // Verify ranges are in correct order
4046 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(key_range.endrust-analyzer cargo text-size 1.1.1 range/impl#[TextRange]end().() <= colon_range.startrust-analyzer cargo text-size 1.1.1 range/impl#[TextRange]start().());
4047 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(colon_range.endrust-analyzer cargo text-size 1.1.1 range/impl#[TextRange]end().() <= value_range.startrust-analyzer cargo text-size 1.1.1 range/impl#[TextRange]start().());
4048 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(key_range.startrust-analyzer cargo text-size 1.1.1 range/impl#[TextRange]start().() >= text_range.startrust-analyzer cargo text-size 1.1.1 range/impl#[TextRange]start().());
4049 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(value_range.endrust-analyzer cargo text-size 1.1.1 range/impl#[TextRange]end().() <= text_range.endrust-analyzer cargo text-size 1.1.1 range/impl#[TextRange]end().());
4050 }
4051
4052 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
4053 fn test_error_recovery_missing_colonrust-analyzer cargo deb822-lossless 0.5.18 lossless/tests/test_error_recovery_missing_colon().() {
4054 let input = r#"Source foo
4055 Maintainer: Test User <[email protected]>
4056 "#;
4057 let (deb822, errors) = superrust-analyzer cargo deb822-lossless 0.5.18 lossless/::Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#::from_str_relaxedrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]from_str_relaxed().(input);
4058
4059 // Should still parse successfully with errors
4060 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().errors.is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().());
4061 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(errors.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().anyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]any().(|e| e.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]contains().("missing colon")));
4062
4063 // Should still have a paragraph with the valid field
4064 let paragraph = deb822.paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraphs().().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().();
4065 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
4066 paragraph.getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("Maintainer").as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(),
4067 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("Test User <[email protected]>")
4068 );
4069 }
4070
4071 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
4072 fn test_error_recovery_missing_field_namerust-analyzer cargo deb822-lossless 0.5.18 lossless/tests/test_error_recovery_missing_field_name().() {
4073 let input = r#": orphaned value
4074 Package: test
4075 "#;
4076
4077 let (deb822, errors) = superrust-analyzer cargo deb822-lossless 0.5.18 lossless/::Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#::from_str_relaxedrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]from_str_relaxed().(input);
4078
4079 // Should have errors about missing field name
4080 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().errors.is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().());
4081 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(errors
4082 .iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().()
4083 .anyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]any().(|e| e.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]contains().("field name") || e.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]contains().("missing")));
4084
4085 // The valid field should be in one of the paragraphs
4086 let paragraphs: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_> = deb822.paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraphs().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().();
4087 let mut found_package = false;
4088 for paragraph in paragraphs.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().() {
4089 if paragraph.getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("Package").is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().() {
4090 found_package = true;
4091 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(paragraph.getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("Package").as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("test"));
4092 }
4093 }
4094 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(found_package, "Package field not found in any paragraph");
4095 }
4096
4097 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
4098 fn test_error_recovery_orphaned_textrust-analyzer cargo deb822-lossless 0.5.18 lossless/tests/test_error_recovery_orphaned_text().() {
4099 let input = r#"Package: test
4100 some orphaned text without field name
4101 Version: 1.0
4102 "#;
4103 let (deb822, errors) = superrust-analyzer cargo deb822-lossless 0.5.18 lossless/::Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#::from_str_relaxedrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]from_str_relaxed().(input);
4104
4105 // Should have errors about orphaned text
4106 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().errors.is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().());
4107 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(errors.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().anyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]any().(|e| e.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]contains().("orphaned")
4108 || e.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]contains().("unexpected")
4109 || e.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]contains().("field name")));
4110
4111 // Should still parse the valid fields (may be split across paragraphs)
4112 let mut all_fields = stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::collectionsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/::HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V>`]new().();
4113 for paragraph in deb822.paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraphs().() {
4114 for (key, value) in paragraph.itemsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]items().() {
4115 all_fields.insertrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]insert().(key, value);
4116 }
4117 }
4118
4119 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(all_fields.getrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]get().("Package"), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&"test".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()));
4120 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(all_fields.getrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]get().("Version"), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&"1.0".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()));
4121 }
4122
4123 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
4124 fn test_error_recovery_consecutive_field_namesrust-analyzer cargo deb822-lossless 0.5.18 lossless/tests/test_error_recovery_consecutive_field_names().() {
4125 let input = r#"Package: test
4126 Description
4127 Maintainer: Another field without proper value
4128 Version: 1.0
4129 "#;
4130 let (deb822, errors) = superrust-analyzer cargo deb822-lossless 0.5.18 lossless/::Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#::from_str_relaxedrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]from_str_relaxed().(input);
4131
4132 // Should have errors about missing values
4133 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().errors.is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().());
4134 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(errors.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().anyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]any().(|e| e.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]contains().("consecutive")
4135 || e.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]contains().("missing")
4136 || e.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]contains().("incomplete")));
4137
4138 // Should still parse valid fields (may be split across paragraphs due to errors)
4139 let mut all_fields = stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::collectionsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/::HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V>`]new().();
4140 for paragraph in deb822.paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraphs().() {
4141 for (key, value) in paragraph.itemsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]items().() {
4142 all_fields.insertrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]insert().(key, value);
4143 }
4144 }
4145
4146 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(all_fields.getrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]get().("Package"), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&"test".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()));
4147 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
4148 all_fields.getrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]get().("Maintainer"),
4149 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&"Another field without proper value".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())
4150 );
4151 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(all_fields.getrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]get().("Version"), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&"1.0".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()));
4152 }
4153
4154 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
4155 fn test_error_recovery_malformed_multilinerust-analyzer cargo deb822-lossless 0.5.18 lossless/tests/test_error_recovery_malformed_multiline().() {
4156 let input = r#"Package: test
4157 Description: Short desc
4158 Proper continuation
4159 invalid continuation without indent
4160 Another proper continuation
4161 Version: 1.0
4162 "#;
4163 let (deb822, errors) = superrust-analyzer cargo deb822-lossless 0.5.18 lossless/::Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#::from_str_relaxedrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]from_str_relaxed().(input);
4164
4165 // Should recover from malformed continuation
4166 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().errors.is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().());
4167
4168 // Should still parse other fields correctly
4169 let paragraph = deb822.paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraphs().().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().();
4170 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(paragraph.getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("Package").as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("test"));
4171 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(paragraph.getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("Version").as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("1.0"));
4172 }
4173
4174 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
4175 fn test_error_recovery_mixed_errorsrust-analyzer cargo deb822-lossless 0.5.18 lossless/tests/test_error_recovery_mixed_errors().() {
4176 let input = r#"Package test without colon
4177 : orphaned colon
4178 Description: Valid field
4179 some orphaned text
4180 Another-Field: Valid too
4181 "#;
4182 let (deb822, errors) = superrust-analyzer cargo deb822-lossless 0.5.18 lossless/::Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#::from_str_relaxedrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]from_str_relaxed().(input);
4183
4184 // Should have multiple different errors
4185 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().errors.is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().());
4186 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(errors.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().() >= 2);
4187
4188 // Should still parse the valid fields
4189 let paragraph = deb822.paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraphs().().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().();
4190 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(paragraph.getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("Description").as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("Valid field"));
4191 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(paragraph.getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("Another-Field").as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("Valid too"));
4192 }
4193
4194 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
4195 fn test_error_recovery_paragraph_boundaryrust-analyzer cargo deb822-lossless 0.5.18 lossless/tests/test_error_recovery_paragraph_boundary().() {
4196 let input = r#"Package: first-package
4197 Description: First paragraph
4198
4199 corrupted data here
4200 : more corruption
4201 completely broken line
4202
4203 Package: second-package
4204 Version: 1.0
4205 "#;
4206 let (deb822, errors) = superrust-analyzer cargo deb822-lossless 0.5.18 lossless/::Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#::from_str_relaxedrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]from_str_relaxed().(input);
4207
4208 // Should have errors from the corrupted section
4209 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().errors.is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().());
4210
4211 // Should still parse both paragraphs correctly
4212 let paragraphs: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_> = deb822.paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraphs().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().();
4213 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(paragraphs.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 2);
4214
4215 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
4216 paragraphs[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()..getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("Package").as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(),
4217 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("first-package")
4218 );
4219 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
4220 paragraphs[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().1]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()..getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("Package").as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(),
4221 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("second-package")
4222 );
4223 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(paragraphs[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().1]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()..getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("Version").as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("1.0"));
4224 }
4225
4226 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
4227 fn test_error_recovery_with_positioned_errorsrust-analyzer cargo deb822-lossless 0.5.18 lossless/tests/test_error_recovery_with_positioned_errors().() {
4228 let input = r#"Package test
4229 Description: Valid
4230 "#;
4231 let parsed = superrust-analyzer cargo deb822-lossless 0.5.18 lossless/::parserust-analyzer cargo deb822-lossless 0.5.18 lossless/parse().(input);
4232
4233 // Should have positioned errors with proper ranges
4234 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().parsed.positioned_errorsrust-analyzer cargo deb822-lossless 0.5.18 lossless/Parse#positioned_errors..is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().());
4235
4236 let first_error = &parsed.positioned_errorsrust-analyzer cargo deb822-lossless 0.5.18 lossless/Parse#positioned_errors.[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().;
4237 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().first_error.messagerust-analyzer cargo deb822-lossless 0.5.18 lossless/PositionedParseError#message..is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]is_empty().());
4238 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(first_error.rangerust-analyzer cargo deb822-lossless 0.5.18 lossless/PositionedParseError#range..startrust-analyzer cargo text-size 1.1.1 range/impl#[TextRange]start().() <= first_error.rangerust-analyzer cargo deb822-lossless 0.5.18 lossless/PositionedParseError#range..endrust-analyzer cargo text-size 1.1.1 range/impl#[TextRange]end().());
4239 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(first_error.coderust-analyzer cargo deb822-lossless 0.5.18 lossless/PositionedParseError#code..is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().());
4240
4241 // Error should point to the problematic location
4242 let error_text = &input[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().first_error.rangerust-analyzer cargo deb822-lossless 0.5.18 lossless/PositionedParseError#range..startrust-analyzer cargo text-size 1.1.1 range/impl#[TextRange]start().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#first_error.rangerust-analyzer cargo deb822-lossless 0.5.18 lossless/PositionedParseError#range..endrust-analyzer cargo text-size 1.1.1 range/impl#[TextRange]end().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().;
4243 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().error_text.is_emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]is_empty().());
4244 }
4245
4246 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
4247 fn test_positioned_error_points_to_correct_tokenrust-analyzer cargo deb822-lossless 0.5.18 lossless/tests/test_positioned_error_points_to_correct_token().() {
4248 let input = "Package test\nDescription: Valid\n";
4249 let parsed = superrust-analyzer cargo deb822-lossless 0.5.18 lossless/::parserust-analyzer cargo deb822-lossless 0.5.18 lossless/parse().(input);
4250
4251 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(parsed.positioned_errorsrust-analyzer cargo deb822-lossless 0.5.18 lossless/Parse#positioned_errors..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 1);
4252
4253 let first_error = &parsed.positioned_errorsrust-analyzer cargo deb822-lossless 0.5.18 lossless/Parse#positioned_errors.[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().;
4254 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(first_error.messagerust-analyzer cargo deb822-lossless 0.5.18 lossless/PositionedParseError#message., "missing colon ':' after field name");
4255 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(first_error.coderust-analyzer cargo deb822-lossless 0.5.18 lossless/PositionedParseError#code..as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("missing_colon"));
4256
4257 let start: usize = first_error.rangerust-analyzer cargo deb822-lossless 0.5.18 lossless/PositionedParseError#range..startrust-analyzer cargo text-size 1.1.1 range/impl#[TextRange]start().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().();
4258 let end: usize = first_error.rangerust-analyzer cargo deb822-lossless 0.5.18 lossless/PositionedParseError#range..endrust-analyzer cargo text-size 1.1.1 range/impl#[TextRange]end().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().();
4259 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(start, 8);
4260 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(end, 12);
4261 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&input[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().start..end]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()., "test");
4262 }
4263
4264 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
4265 fn test_error_recovery_preserves_whitespacerust-analyzer cargo deb822-lossless 0.5.18 lossless/tests/test_error_recovery_preserves_whitespace().() {
4266 let input = r#"Source: package
4267 Maintainer Test User <[email protected]>
4268 Section: utils
4269
4270 "#;
4271 let (deb822, errors) = superrust-analyzer cargo deb822-lossless 0.5.18 lossless/::Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#::from_str_relaxedrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]from_str_relaxed().(input);
4272
4273 // Should have error about missing colon
4274 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().errors.is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().());
4275
4276 // Should preserve original formatting in output
4277 let output = deb822.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().();
4278 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(output.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]contains().("Section: utils"));
4279
4280 // Should still extract valid fields
4281 let paragraph = deb822.paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraphs().().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().();
4282 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(paragraph.getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("Source").as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("package"));
4283 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(paragraph.getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("Section").as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("utils"));
4284 }
4285
4286 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
4287 fn test_error_recovery_empty_fieldsrust-analyzer cargo deb822-lossless 0.5.18 lossless/tests/test_error_recovery_empty_fields().() {
4288 let input = r#"Package: test
4289 Description:
4290 Maintainer: Valid User
4291 EmptyField:
4292 Version: 1.0
4293 "#;
4294 let (deb822, _errors) = superrust-analyzer cargo deb822-lossless 0.5.18 lossless/::Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#::from_str_relaxedrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]from_str_relaxed().(input);
4295
4296 // Empty fields should parse without major errors - collect all fields from all paragraphs
4297 let mut all_fields = stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::collectionsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/::HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V>`]new().();
4298 for paragraph in deb822.paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraphs().() {
4299 for (key, value) in paragraph.itemsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]items().() {
4300 all_fields.insertrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]insert().(key, value);
4301 }
4302 }
4303
4304 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(all_fields.getrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]get().("Package"), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&"test".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()));
4305 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(all_fields.getrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]get().("Description"), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&"".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()));
4306 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
4307 all_fields.getrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]get().("Maintainer"),
4308 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&"Valid User".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())
4309 );
4310 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(all_fields.getrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]get().("EmptyField"), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&"".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()));
4311 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(all_fields.getrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]get().("Version"), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&"1.0".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()));
4312 }
4313
4314 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
4315 fn test_insert_comment_beforerust-analyzer cargo deb822-lossless 0.5.18 lossless/tests/test_insert_comment_before().() {
4316 let d: superrust-analyzer cargo deb822-lossless 0.5.18 lossless/::Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822# = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![
4317 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![("Source", "foo"), ("Maintainer", "Bar <[email protected]>")]
4318 .into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().()
4319 .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(),
4320 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![("Package", "foo"), ("Architecture", "all")]
4321 .into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().()
4322 .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(),
4323 ]
4324 .into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().()
4325 .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().();
4326
4327 // Insert comment before first paragraph
4328 let mut p1 = d.paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraphs().().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().();
4329 p1.insert_comment_beforerust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]insert_comment_before().("This is the source paragraph");
4330
4331 // Insert comment before second paragraph
4332 let mut p2 = d.paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraphs().().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().();
4333 p2.insert_comment_beforerust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]insert_comment_before().("This is the binary paragraph");
4334
4335 let output = d.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().();
4336 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
4337 output,
4338 r#"# This is the source paragraph
4339 Source: foo
4340 Maintainer: Bar <[email protected]>
4341
4342 # This is the binary paragraph
4343 Package: foo
4344 Architecture: all
4345 "#
4346 );
4347 }
4348
4349 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
4350 fn test_parse_continuation_with_colonrust-analyzer cargo deb822-lossless 0.5.18 lossless/tests/test_parse_continuation_with_colon().() {
4351 // Test that continuation lines with colons are properly parsed
4352 let input = "Package: test\nDescription: short\n line: with colon\n";
4353 let result = input.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().::<Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#>();
4354 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(result.is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().());
4355
4356 let deb822 = result.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
4357 let para = deb822.paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraphs().().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().();
4358 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(para.getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("Package").as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("test"));
4359 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
4360 para.getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("Description").as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(),
4361 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("short\nline: with colon")
4362 );
4363 }
4364
4365 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
4366 fn test_parse_continuation_starting_with_colonrust-analyzer cargo deb822-lossless 0.5.18 lossless/tests/test_parse_continuation_starting_with_colon().() {
4367 // Test continuation line STARTING with a colon (issue #315)
4368 let input = "Package: test\nDescription: short\n :value\n";
4369 let result = input.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().::<Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#>();
4370 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(result.is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().());
4371
4372 let deb822 = result.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
4373 let para = deb822.paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraphs().().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().();
4374 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(para.getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("Package").as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("test"));
4375 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(para.getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("Description").as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("short\n:value"));
4376 }
4377
4378 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
4379 fn test_normalize_field_spacing_single_spacerust-analyzer cargo deb822-lossless 0.5.18 lossless/tests/test_normalize_field_spacing_single_space().() {
4380 // Field already has correct spacing
4381 let input = "Field: value\n";
4382 let deb822 = input.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().::<Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#>().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
4383 let mut para = deb822.paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraphs().().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().();
4384
4385 para.normalize_field_spacingrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]normalize_field_spacing().();
4386 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(para.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "Field: value\n");
4387 }
4388
4389 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
4390 fn test_normalize_field_spacing_extra_spacesrust-analyzer cargo deb822-lossless 0.5.18 lossless/tests/test_normalize_field_spacing_extra_spaces().() {
4391 // Field has extra spaces after colon
4392 let input = "Field: value\n";
4393 let deb822 = input.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().::<Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#>().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
4394 let mut para = deb822.paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraphs().().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().();
4395
4396 para.normalize_field_spacingrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]normalize_field_spacing().();
4397 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(para.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "Field: value\n");
4398 }
4399
4400 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
4401 fn test_normalize_field_spacing_no_spacerust-analyzer cargo deb822-lossless 0.5.18 lossless/tests/test_normalize_field_spacing_no_space().() {
4402 // Field has no space after colon
4403 let input = "Field:value\n";
4404 let deb822 = input.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().::<Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#>().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
4405 let mut para = deb822.paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraphs().().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().();
4406
4407 para.normalize_field_spacingrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]normalize_field_spacing().();
4408 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(para.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "Field: value\n");
4409 }
4410
4411 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
4412 fn test_normalize_field_spacing_multiple_fieldsrust-analyzer cargo deb822-lossless 0.5.18 lossless/tests/test_normalize_field_spacing_multiple_fields().() {
4413 // Multiple fields with various spacing
4414 let input = "Field1: value1\nField2:value2\nField3: value3\n";
4415 let deb822 = input.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().::<Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#>().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
4416 let mut para = deb822.paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraphs().().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().();
4417
4418 para.normalize_field_spacingrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]normalize_field_spacing().();
4419 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
4420 para.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(),
4421 "Field1: value1\nField2: value2\nField3: value3\n"
4422 );
4423 }
4424
4425 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
4426 fn test_normalize_field_spacing_multiline_valuerust-analyzer cargo deb822-lossless 0.5.18 lossless/tests/test_normalize_field_spacing_multiline_value().() {
4427 // Field with multiline value
4428 let input = "Description: short\n continuation line\n . \n final line\n";
4429 let deb822 = input.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().::<Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#>().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
4430 let mut para = deb822.paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraphs().().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().();
4431
4432 para.normalize_field_spacingrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]normalize_field_spacing().();
4433 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
4434 para.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(),
4435 "Description: short\n continuation line\n . \n final line\n"
4436 );
4437 }
4438
4439 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
4440 fn test_normalize_field_spacing_empty_value_with_whitespacerust-analyzer cargo deb822-lossless 0.5.18 lossless/tests/test_normalize_field_spacing_empty_value_with_whitespace().() {
4441 // Field with empty value (only whitespace) should normalize to no space
4442 let input = "Field: \n";
4443 let deb822 = input.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().::<Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#>().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
4444 let mut para = deb822.paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraphs().().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().();
4445
4446 para.normalize_field_spacingrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]normalize_field_spacing().();
4447 // When value is empty/whitespace-only, normalize to no space
4448 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(para.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "Field:\n");
4449 }
4450
4451 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
4452 fn test_normalize_field_spacing_no_valuerust-analyzer cargo deb822-lossless 0.5.18 lossless/tests/test_normalize_field_spacing_no_value().() {
4453 // Field with no value (just newline) should stay unchanged
4454 let input = "Depends:\n";
4455 let deb822 = input.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().::<Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#>().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
4456 let mut para = deb822.paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraphs().().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().();
4457
4458 para.normalize_field_spacingrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]normalize_field_spacing().();
4459 // Should remain with no space
4460 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(para.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "Depends:\n");
4461 }
4462
4463 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
4464 fn test_normalize_field_spacing_multiple_paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/tests/test_normalize_field_spacing_multiple_paragraphs().() {
4465 // Multiple paragraphs
4466 let input = "Field1: value1\n\nField2: value2\n";
4467 let mut deb822 = input.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().::<Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#>().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
4468
4469 deb822.normalize_field_spacingrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]normalize_field_spacing().();
4470 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(deb822.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "Field1: value1\n\nField2: value2\n");
4471 }
4472
4473 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
4474 fn test_normalize_field_spacing_preserves_commentsrust-analyzer cargo deb822-lossless 0.5.18 lossless/tests/test_normalize_field_spacing_preserves_comments().() {
4475 // Normalize spacing while preserving comments (comments are at document level)
4476 let input = "# Comment\nField: value\n";
4477 let mut deb822 = input.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().::<Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#>().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
4478
4479 deb822.normalize_field_spacingrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]normalize_field_spacing().();
4480 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(deb822.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "# Comment\nField: value\n");
4481 }
4482
4483 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
4484 fn test_normalize_field_spacing_preserves_valuesrust-analyzer cargo deb822-lossless 0.5.18 lossless/tests/test_normalize_field_spacing_preserves_values().() {
4485 // Ensure values are preserved exactly
4486 let input = "Source: foo-bar\nMaintainer:Foo Bar <[email protected]>\n";
4487 let deb822 = input.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().::<Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#>().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
4488 let mut para = deb822.paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraphs().().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().();
4489
4490 para.normalize_field_spacingrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]normalize_field_spacing().();
4491
4492 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(para.getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("Source").as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("foo-bar"));
4493 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
4494 para.getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("Maintainer").as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(),
4495 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("Foo Bar <[email protected]>")
4496 );
4497 }
4498
4499 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
4500 fn test_normalize_field_spacing_tab_after_colonrust-analyzer cargo deb822-lossless 0.5.18 lossless/tests/test_normalize_field_spacing_tab_after_colon().() {
4501 // Field with tab after colon (should be normalized to single space)
4502 let input = "Field:\tvalue\n";
4503 let deb822 = input.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().::<Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#>().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
4504 let mut para = deb822.paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraphs().().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().();
4505
4506 para.normalize_field_spacingrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]normalize_field_spacing().();
4507 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(para.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "Field: value\n");
4508 }
4509
4510 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
4511 fn test_set_preserves_indentationrust-analyzer cargo deb822-lossless 0.5.18 lossless/tests/test_set_preserves_indentation().() {
4512 // Test that Paragraph.set() preserves the original indentation
4513 let original = r#"Source: example
4514 Build-Depends: foo,
4515 bar,
4516 baz
4517 "#;
4518
4519 let mut para: superrust-analyzer cargo deb822-lossless 0.5.18 lossless/::Paragraphrust-analyzer cargo deb822-lossless 0.5.18 lossless/Paragraph# = original.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().();
4520
4521 // Modify the Build-Depends field
4522 para.setrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]set().("Build-Depends", "foo,\nbar,\nbaz");
4523
4524 // The indentation should be preserved (15 spaces for "Build-Depends: ")
4525 let expected = r#"Source: example
4526 Build-Depends: foo,
4527 bar,
4528 baz
4529 "#;
4530 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(para.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), expected);
4531 }
4532
4533 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
4534 fn test_set_new_field_detects_field_name_length_indentrust-analyzer cargo deb822-lossless 0.5.18 lossless/tests/test_set_new_field_detects_field_name_length_indent().() {
4535 // Test that new fields detect field-name-length-based indentation
4536 let original = r#"Source: example
4537 Build-Depends: foo,
4538 bar,
4539 baz
4540 Depends: lib1,
4541 lib2
4542 "#;
4543
4544 let mut para: superrust-analyzer cargo deb822-lossless 0.5.18 lossless/::Paragraphrust-analyzer cargo deb822-lossless 0.5.18 lossless/Paragraph# = original.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().();
4545
4546 // Add a new multi-line field - should detect that indentation is field-name-length + 2
4547 para.setrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]set().("Recommends", "pkg1,\npkg2,\npkg3");
4548
4549 // "Recommends: " is 12 characters, so indentation should be 12 spaces
4550 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(para
4551 .to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()
4552 .containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]contains().("Recommends: pkg1,\n pkg2,"));
4553 }
4554
4555 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
4556 fn test_set_new_field_detects_fixed_indentrust-analyzer cargo deb822-lossless 0.5.18 lossless/tests/test_set_new_field_detects_fixed_indent().() {
4557 // Test that new fields detect fixed indentation pattern
4558 let original = r#"Source: example
4559 Build-Depends: foo,
4560 bar,
4561 baz
4562 Depends: lib1,
4563 lib2
4564 "#;
4565
4566 let mut para: superrust-analyzer cargo deb822-lossless 0.5.18 lossless/::Paragraphrust-analyzer cargo deb822-lossless 0.5.18 lossless/Paragraph# = original.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().();
4567
4568 // Add a new multi-line field - should detect fixed 5-space indentation
4569 para.setrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]set().("Recommends", "pkg1,\npkg2,\npkg3");
4570
4571 // Should use the same 5-space indentation
4572 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(para
4573 .to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()
4574 .containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]contains().("Recommends: pkg1,\n pkg2,\n pkg3\n"));
4575 }
4576
4577 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
4578 fn test_set_new_field_no_multiline_fieldsrust-analyzer cargo deb822-lossless 0.5.18 lossless/tests/test_set_new_field_no_multiline_fields().() {
4579 // Test that new fields use field-name-length when no existing multi-line fields
4580 let original = r#"Source: example
4581 Maintainer: Test <[email protected]>
4582 "#;
4583
4584 let mut para: superrust-analyzer cargo deb822-lossless 0.5.18 lossless/::Paragraphrust-analyzer cargo deb822-lossless 0.5.18 lossless/Paragraph# = original.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().();
4585
4586 // Add a new multi-line field - should default to field name length + 2
4587 para.setrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]set().("Depends", "foo,\nbar,\nbaz");
4588
4589 // "Depends: " is 9 characters, so indentation should be 9 spaces
4590 let expected = r#"Source: example
4591 Maintainer: Test <[email protected]>
4592 Depends: foo,
4593 bar,
4594 baz
4595 "#;
4596 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(para.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), expected);
4597 }
4598
4599 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
4600 fn test_set_new_field_mixed_indentationrust-analyzer cargo deb822-lossless 0.5.18 lossless/tests/test_set_new_field_mixed_indentation().() {
4601 // Test that new fields fall back to field-name-length when pattern is inconsistent
4602 let original = r#"Source: example
4603 Build-Depends: foo,
4604 bar
4605 Depends: lib1,
4606 lib2
4607 "#;
4608
4609 let mut para: superrust-analyzer cargo deb822-lossless 0.5.18 lossless/::Paragraphrust-analyzer cargo deb822-lossless 0.5.18 lossless/Paragraph# = original.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().();
4610
4611 // Add a new multi-line field - mixed pattern, should fall back to field name length + 2
4612 para.setrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]set().("Recommends", "pkg1,\npkg2");
4613
4614 // "Recommends: " is 12 characters
4615 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(para
4616 .to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()
4617 .containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]contains().("Recommends: pkg1,\n pkg2\n"));
4618 }
4619
4620 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
4621 fn test_entry_with_indentationrust-analyzer cargo deb822-lossless 0.5.18 lossless/tests/test_entry_with_indentation().() {
4622 // Test Entry::with_indentation directly
4623 let entry = superrust-analyzer cargo deb822-lossless 0.5.18 lossless/::Entryrust-analyzer cargo deb822-lossless 0.5.18 lossless/Entry#::with_indentationrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]with_indentation().("Test-Field", "value1\nvalue2\nvalue3", " ");
4624
4625 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
4626 entry.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(),
4627 "Test-Field: value1\n value2\n value3\n"
4628 );
4629 }
4630
4631 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
4632 fn test_set_with_indent_pattern_fixedrust-analyzer cargo deb822-lossless 0.5.18 lossless/tests/test_set_with_indent_pattern_fixed().() {
4633 // Test setting a field with explicit fixed indentation pattern
4634 let original = r#"Source: example
4635 Maintainer: Test <[email protected]>
4636 "#;
4637
4638 let mut para: superrust-analyzer cargo deb822-lossless 0.5.18 lossless/::Paragraphrust-analyzer cargo deb822-lossless 0.5.18 lossless/Paragraph# = original.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().();
4639
4640 // Add a new multi-line field with fixed 4-space indentation
4641 para.set_with_indent_patternrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]set_with_indent_pattern().(
4642 "Depends",
4643 "foo,\nbar,\nbaz",
4644 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&superrust-analyzer cargo deb822-lossless 0.5.18 lossless/::IndentPatternrust-analyzer cargo deb822-lossless 0.5.18 lossless/IndentPattern#::Fixedrust-analyzer cargo deb822-lossless 0.5.18 lossless/IndentPattern#Fixed#(4)),
4645 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
4646 );
4647
4648 // Should use the specified 4-space indentation
4649 let expected = r#"Source: example
4650 Maintainer: Test <[email protected]>
4651 Depends: foo,
4652 bar,
4653 baz
4654 "#;
4655 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(para.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), expected);
4656 }
4657
4658 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
4659 fn test_set_with_indent_pattern_field_name_lengthrust-analyzer cargo deb822-lossless 0.5.18 lossless/tests/test_set_with_indent_pattern_field_name_length().() {
4660 // Test setting a field with field-name-length indentation pattern
4661 let original = r#"Source: example
4662 Maintainer: Test <[email protected]>
4663 "#;
4664
4665 let mut para: superrust-analyzer cargo deb822-lossless 0.5.18 lossless/::Paragraphrust-analyzer cargo deb822-lossless 0.5.18 lossless/Paragraph# = original.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().();
4666
4667 // Add a new multi-line field with field-name-length indentation
4668 para.set_with_indent_patternrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]set_with_indent_pattern().(
4669 "Build-Depends",
4670 "libfoo,\nlibbar,\nlibbaz",
4671 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&superrust-analyzer cargo deb822-lossless 0.5.18 lossless/::IndentPatternrust-analyzer cargo deb822-lossless 0.5.18 lossless/IndentPattern#::FieldNameLengthrust-analyzer cargo deb822-lossless 0.5.18 lossless/IndentPattern#FieldNameLength#),
4672 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
4673 );
4674
4675 // "Build-Depends: " is 15 characters, so indentation should be 15 spaces
4676 let expected = r#"Source: example
4677 Maintainer: Test <[email protected]>
4678 Build-Depends: libfoo,
4679 libbar,
4680 libbaz
4681 "#;
4682 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(para.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), expected);
4683 }
4684
4685 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
4686 fn test_set_with_indent_pattern_override_auto_detectionrust-analyzer cargo deb822-lossless 0.5.18 lossless/tests/test_set_with_indent_pattern_override_auto_detection().() {
4687 // Test that explicit default pattern overrides auto-detection for new fields
4688 let original = r#"Source: example
4689 Build-Depends: foo,
4690 bar,
4691 baz
4692 "#;
4693
4694 let mut para: superrust-analyzer cargo deb822-lossless 0.5.18 lossless/::Paragraphrust-analyzer cargo deb822-lossless 0.5.18 lossless/Paragraph# = original.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().();
4695
4696 // Add a NEW field with fixed 2-space indentation, overriding the auto-detected pattern
4697 para.set_with_indent_patternrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]set_with_indent_pattern().(
4698 "Depends",
4699 "lib1,\nlib2,\nlib3",
4700 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&superrust-analyzer cargo deb822-lossless 0.5.18 lossless/::IndentPatternrust-analyzer cargo deb822-lossless 0.5.18 lossless/IndentPattern#::Fixedrust-analyzer cargo deb822-lossless 0.5.18 lossless/IndentPattern#Fixed#(2)),
4701 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
4702 );
4703
4704 // Should use the specified 2-space indentation, not the auto-detected 15-space
4705 let expected = r#"Source: example
4706 Build-Depends: foo,
4707 bar,
4708 baz
4709 Depends: lib1,
4710 lib2,
4711 lib3
4712 "#;
4713 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(para.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), expected);
4714 }
4715
4716 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
4717 fn test_set_with_indent_pattern_none_auto_detectsrust-analyzer cargo deb822-lossless 0.5.18 lossless/tests/test_set_with_indent_pattern_none_auto_detects().() {
4718 // Test that None pattern auto-detects from existing fields
4719 let original = r#"Source: example
4720 Build-Depends: foo,
4721 bar,
4722 baz
4723 "#;
4724
4725 let mut para: superrust-analyzer cargo deb822-lossless 0.5.18 lossless/::Paragraphrust-analyzer cargo deb822-lossless 0.5.18 lossless/Paragraph# = original.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().();
4726
4727 // Add a field with None pattern - should auto-detect fixed 5-space
4728 para.set_with_indent_patternrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]set_with_indent_pattern().("Depends", "lib1,\nlib2", 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#);
4729
4730 // Should auto-detect and use the 5-space indentation
4731 let expected = r#"Source: example
4732 Build-Depends: foo,
4733 bar,
4734 baz
4735 Depends: lib1,
4736 lib2
4737 "#;
4738 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(para.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), expected);
4739 }
4740
4741 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
4742 fn test_set_with_indent_pattern_with_field_orderrust-analyzer cargo deb822-lossless 0.5.18 lossless/tests/test_set_with_indent_pattern_with_field_order().() {
4743 // Test setting a field with both indent pattern and field ordering
4744 let original = r#"Source: example
4745 Maintainer: Test <[email protected]>
4746 "#;
4747
4748 let mut para: superrust-analyzer cargo deb822-lossless 0.5.18 lossless/::Paragraphrust-analyzer cargo deb822-lossless 0.5.18 lossless/Paragraph# = original.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().();
4749
4750 // Add a field with fixed indentation and specific field ordering
4751 para.set_with_indent_patternrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]set_with_indent_pattern().(
4752 "Priority",
4753 "optional",
4754 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&superrust-analyzer cargo deb822-lossless 0.5.18 lossless/::IndentPatternrust-analyzer cargo deb822-lossless 0.5.18 lossless/IndentPattern#::Fixedrust-analyzer cargo deb822-lossless 0.5.18 lossless/IndentPattern#Fixed#(4)),
4755 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&["Source", "Priority", "Maintainer"]),
4756 );
4757
4758 // Priority should be inserted between Source and Maintainer
4759 let expected = r#"Source: example
4760 Priority: optional
4761 Maintainer: Test <[email protected]>
4762 "#;
4763 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(para.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), expected);
4764 }
4765
4766 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
4767 fn test_set_with_indent_pattern_replace_existingrust-analyzer cargo deb822-lossless 0.5.18 lossless/tests/test_set_with_indent_pattern_replace_existing().() {
4768 // Test that replacing an existing multi-line field preserves its indentation
4769 let original = r#"Source: example
4770 Depends: foo,
4771 bar
4772 "#;
4773
4774 let mut para: superrust-analyzer cargo deb822-lossless 0.5.18 lossless/::Paragraphrust-analyzer cargo deb822-lossless 0.5.18 lossless/Paragraph# = original.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().();
4775
4776 // Replace Depends - the default pattern is ignored, existing indentation is preserved
4777 para.set_with_indent_patternrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]set_with_indent_pattern().(
4778 "Depends",
4779 "lib1,\nlib2,\nlib3",
4780 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&superrust-analyzer cargo deb822-lossless 0.5.18 lossless/::IndentPatternrust-analyzer cargo deb822-lossless 0.5.18 lossless/IndentPattern#::Fixedrust-analyzer cargo deb822-lossless 0.5.18 lossless/IndentPattern#Fixed#(3)),
4781 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
4782 );
4783
4784 // Should preserve the existing 9-space indentation, not use the default 3-space
4785 let expected = r#"Source: example
4786 Depends: lib1,
4787 lib2,
4788 lib3
4789 "#;
4790 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(para.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), expected);
4791 }
4792
4793 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
4794 fn test_change_field_indentrust-analyzer cargo deb822-lossless 0.5.18 lossless/tests/test_change_field_indent().() {
4795 // Test changing indentation of an existing field without changing its value
4796 let original = r#"Source: example
4797 Depends: foo,
4798 bar,
4799 baz
4800 "#;
4801 let mut para: superrust-analyzer cargo deb822-lossless 0.5.18 lossless/::Paragraphrust-analyzer cargo deb822-lossless 0.5.18 lossless/Paragraph# = original.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().();
4802
4803 // Change Depends field to use 2-space indentation
4804 let result = para
4805 .change_field_indentrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]change_field_indent().("Depends", &superrust-analyzer cargo deb822-lossless 0.5.18 lossless/::IndentPatternrust-analyzer cargo deb822-lossless 0.5.18 lossless/IndentPattern#::Fixedrust-analyzer cargo deb822-lossless 0.5.18 lossless/IndentPattern#Fixed#(2))
4806 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
4807 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(result, "Field should have been found and updated");
4808
4809 let expected = r#"Source: example
4810 Depends: foo,
4811 bar,
4812 baz
4813 "#;
4814 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(para.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), expected);
4815 }
4816
4817 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
4818 fn test_change_field_indent_nonexistentrust-analyzer cargo deb822-lossless 0.5.18 lossless/tests/test_change_field_indent_nonexistent().() {
4819 // Test changing indentation of a non-existent field
4820 let original = r#"Source: example
4821 "#;
4822 let mut para: superrust-analyzer cargo deb822-lossless 0.5.18 lossless/::Paragraphrust-analyzer cargo deb822-lossless 0.5.18 lossless/Paragraph# = original.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().();
4823
4824 // Try to change indentation of non-existent field
4825 let result = para
4826 .change_field_indentrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]change_field_indent().("Depends", &superrust-analyzer cargo deb822-lossless 0.5.18 lossless/::IndentPatternrust-analyzer cargo deb822-lossless 0.5.18 lossless/IndentPattern#::Fixedrust-analyzer cargo deb822-lossless 0.5.18 lossless/IndentPattern#Fixed#(2))
4827 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
4828 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().result, "Should return false for non-existent field");
4829
4830 // Paragraph should be unchanged
4831 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(para.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), original);
4832 }
4833
4834 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
4835 fn test_change_field_indent_case_insensitiverust-analyzer cargo deb822-lossless 0.5.18 lossless/tests/test_change_field_indent_case_insensitive().() {
4836 // Test that change_field_indent is case-insensitive
4837 let original = r#"Build-Depends: foo,
4838 bar
4839 "#;
4840 let mut para: superrust-analyzer cargo deb822-lossless 0.5.18 lossless/::Paragraphrust-analyzer cargo deb822-lossless 0.5.18 lossless/Paragraph# = original.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().();
4841
4842 // Change using different case
4843 let result = para
4844 .change_field_indentrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]change_field_indent().("build-depends", &superrust-analyzer cargo deb822-lossless 0.5.18 lossless/::IndentPatternrust-analyzer cargo deb822-lossless 0.5.18 lossless/IndentPattern#::Fixedrust-analyzer cargo deb822-lossless 0.5.18 lossless/IndentPattern#Fixed#(1))
4845 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
4846 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(result, "Should find field case-insensitively");
4847
4848 let expected = r#"Build-Depends: foo,
4849 bar
4850 "#;
4851 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(para.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), expected);
4852 }
4853
4854 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
4855 fn test_entry_get_indentrust-analyzer cargo deb822-lossless 0.5.18 lossless/tests/test_entry_get_indent().() {
4856 // Test that we can extract indentation from an entry
4857 let original = r#"Build-Depends: foo,
4858 bar,
4859 baz
4860 "#;
4861 let para: superrust-analyzer cargo deb822-lossless 0.5.18 lossless/::Paragraphrust-analyzer cargo deb822-lossless 0.5.18 lossless/Paragraph# = original.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().();
4862 let entry = para.entriesrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]entries().().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().();
4863
4864 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(entry.get_indentrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]get_indent().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(" ".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()));
4865 }
4866
4867 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
4868 fn test_entry_get_indent_single_linerust-analyzer cargo deb822-lossless 0.5.18 lossless/tests/test_entry_get_indent_single_line().() {
4869 // Single-line entries should return None for indentation
4870 let original = r#"Source: example
4871 "#;
4872 let para: superrust-analyzer cargo deb822-lossless 0.5.18 lossless/::Paragraphrust-analyzer cargo deb822-lossless 0.5.18 lossless/Paragraph# = original.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().();
4873 let entry = para.entriesrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]entries().().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().();
4874
4875 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(entry.get_indentrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]get_indent().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
4876 }
4877 }
4878
4879 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
4880 fn test_move_paragraph_forwardrust-analyzer cargo deb822-lossless 0.5.18 lossless/test_move_paragraph_forward().() {
4881 let mut d: Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822# = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![
4882 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![("Foo", "Bar"), ("Baz", "Qux")].into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(),
4883 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![("A", "B"), ("C", "D")].into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(),
4884 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![("X", "Y"), ("Z", "W")].into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(),
4885 ]
4886 .into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().()
4887 .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().();
4888 d.move_paragraphrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]move_paragraph().(0, 2);
4889 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
4890 d.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(),
4891 "A: B\nC: D\n\nX: Y\nZ: W\n\nFoo: Bar\nBaz: Qux\n"
4892 );
4893 }
4894
4895 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
4896 fn test_move_paragraph_backwardrust-analyzer cargo deb822-lossless 0.5.18 lossless/test_move_paragraph_backward().() {
4897 let mut d: Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822# = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![
4898 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![("Foo", "Bar"), ("Baz", "Qux")].into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(),
4899 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![("A", "B"), ("C", "D")].into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(),
4900 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![("X", "Y"), ("Z", "W")].into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(),
4901 ]
4902 .into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().()
4903 .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().();
4904 d.move_paragraphrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]move_paragraph().(2, 0);
4905 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
4906 d.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(),
4907 "X: Y\nZ: W\n\nFoo: Bar\nBaz: Qux\n\nA: B\nC: D\n"
4908 );
4909 }
4910
4911 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
4912 fn test_move_paragraph_middlerust-analyzer cargo deb822-lossless 0.5.18 lossless/test_move_paragraph_middle().() {
4913 let mut d: Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822# = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![
4914 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![("Foo", "Bar"), ("Baz", "Qux")].into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(),
4915 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![("A", "B"), ("C", "D")].into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(),
4916 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![("X", "Y"), ("Z", "W")].into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(),
4917 ]
4918 .into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().()
4919 .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().();
4920 d.move_paragraphrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]move_paragraph().(2, 1);
4921 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
4922 d.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(),
4923 "Foo: Bar\nBaz: Qux\n\nX: Y\nZ: W\n\nA: B\nC: D\n"
4924 );
4925 }
4926
4927 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
4928 fn test_move_paragraph_same_indexrust-analyzer cargo deb822-lossless 0.5.18 lossless/test_move_paragraph_same_index().() {
4929 let mut d: Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822# = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![
4930 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![("Foo", "Bar"), ("Baz", "Qux")].into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(),
4931 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![("A", "B"), ("C", "D")].into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(),
4932 ]
4933 .into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().()
4934 .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().();
4935 let original = d.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().();
4936 d.move_paragraphrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]move_paragraph().(1, 1);
4937 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(d.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), original);
4938 }
4939
4940 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
4941 fn test_move_paragraph_singlerust-analyzer cargo deb822-lossless 0.5.18 lossless/test_move_paragraph_single().() {
4942 let mut d: Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822# = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![("Foo", "Bar")].into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().()]
4943 .into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().()
4944 .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().();
4945 let original = d.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().();
4946 d.move_paragraphrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]move_paragraph().(0, 0);
4947 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(d.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), original);
4948 }
4949
4950 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
4951 fn test_move_paragraph_invalid_indexrust-analyzer cargo deb822-lossless 0.5.18 lossless/test_move_paragraph_invalid_index().() {
4952 let mut d: Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822# = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![
4953 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![("Foo", "Bar")].into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(),
4954 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![("A", "B")].into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(),
4955 ]
4956 .into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().()
4957 .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().();
4958 let original = d.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().();
4959 d.move_paragraphrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]move_paragraph().(0, 5);
4960 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(d.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), original);
4961 }
4962
4963 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
4964 fn test_move_paragraph_with_commentsrust-analyzer cargo deb822-lossless 0.5.18 lossless/test_move_paragraph_with_comments().() {
4965 let text = r#"Foo: Bar
4966
4967 # This is a comment
4968
4969 A: B
4970
4971 X: Y
4972 "#;
4973 let mut d: Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822# = text.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().();
4974 d.move_paragraphrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]move_paragraph().(0, 2);
4975 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
4976 d.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(),
4977 "# This is a comment\n\nA: B\n\nX: Y\n\nFoo: Bar\n"
4978 );
4979 }
4980
4981 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
4982 fn test_case_insensitive_getrust-analyzer cargo deb822-lossless 0.5.18 lossless/test_case_insensitive_get().() {
4983 let text = "Package: test\nVersion: 1.0\n";
4984 let d: Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822# = text.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().();
4985 let p = d.paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraphs().().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().();
4986
4987 // Test different case variations
4988 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(p.getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("Package").as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("test"));
4989 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(p.getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("package").as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("test"));
4990 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(p.getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("PACKAGE").as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("test"));
4991 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(p.getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("PaCkAgE").as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("test"));
4992
4993 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(p.getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("Version").as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("1.0"));
4994 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(p.getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("version").as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("1.0"));
4995 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(p.getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("VERSION").as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("1.0"));
4996 }
4997
4998 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
4999 fn test_case_insensitive_setrust-analyzer cargo deb822-lossless 0.5.18 lossless/test_case_insensitive_set().() {
5000 let text = "Package: test\n";
5001 let d: Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822# = text.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().();
5002 let mut p = d.paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraphs().().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().();
5003
5004 // Set with different case should update the existing field
5005 p.setrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]set().("package", "updated");
5006 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(p.getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("Package").as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("updated"));
5007 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(p.getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("package").as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("updated"));
5008
5009 // Set with UPPERCASE
5010 p.setrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]set().("PACKAGE", "updated2");
5011 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(p.getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("Package").as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("updated2"));
5012
5013 // Field count should remain 1
5014 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(p.keysrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]keys().().countrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#count().(), 1);
5015 }
5016
5017 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
5018 fn test_case_insensitive_removerust-analyzer cargo deb822-lossless 0.5.18 lossless/test_case_insensitive_remove().() {
5019 let text = "Package: test\nVersion: 1.0\n";
5020 let d: Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822# = text.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().();
5021 let mut p = d.paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraphs().().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().();
5022
5023 // Remove with different case
5024 p.removerust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]remove().("package");
5025 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(p.getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("Package"), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
5026 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(p.getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("Version").as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("1.0"));
5027
5028 // Remove with uppercase
5029 p.removerust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]remove().("VERSION");
5030 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(p.getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("Version"), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
5031
5032 // No fields left
5033 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(p.keysrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]keys().().countrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#count().(), 0);
5034 }
5035
5036 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
5037 fn test_case_preservationrust-analyzer cargo deb822-lossless 0.5.18 lossless/test_case_preservation().() {
5038 let text = "Package: test\n";
5039 let d: Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822# = text.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().();
5040 let mut p = d.paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraphs().().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().();
5041
5042 // Original case should be preserved
5043 let original_text = d.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().();
5044 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(original_text, "Package: test\n");
5045
5046 // Set with different case should preserve original case
5047 p.setrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]set().("package", "updated");
5048
5049 // The field name should still be "Package" (original case preserved)
5050 let updated_text = d.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().();
5051 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(updated_text, "Package: updated\n");
5052 }
5053
5054 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
5055 fn test_case_insensitive_contains_keyrust-analyzer cargo deb822-lossless 0.5.18 lossless/test_case_insensitive_contains_key().() {
5056 let text = "Package: test\n";
5057 let d: Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822# = text.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().();
5058 let p = d.paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraphs().().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().();
5059
5060 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(p.contains_keyrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]contains_key().("Package"));
5061 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(p.contains_keyrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]contains_key().("package"));
5062 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(p.contains_keyrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]contains_key().("PACKAGE"));
5063 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().p.contains_keyrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]contains_key().("NonExistent"));
5064 }
5065
5066 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
5067 fn test_case_insensitive_get_allrust-analyzer cargo deb822-lossless 0.5.18 lossless/test_case_insensitive_get_all().() {
5068 let text = "Package: test1\npackage: test2\n";
5069 let d: Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822# = text.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().();
5070 let p = d.paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraphs().().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().();
5071
5072 let values: 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#> = p.get_allrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get_all().("PACKAGE").collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().();
5073 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(values, vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!!["test1", "test2"]);
5074 }
5075
5076 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
5077 fn test_case_insensitive_renamerust-analyzer cargo deb822-lossless 0.5.18 lossless/test_case_insensitive_rename().() {
5078 let text = "Package: test\n";
5079 let d: Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822# = text.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().();
5080 let mut p = d.paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraphs().().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().();
5081
5082 // Rename with different case
5083 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(p.renamerust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]rename().("package", "NewName"));
5084 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(p.getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("NewName").as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("test"));
5085 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(p.getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("Package"), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
5086 }
5087
5088 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
5089 fn test_rename_changes_caserust-analyzer cargo deb822-lossless 0.5.18 lossless/test_rename_changes_case().() {
5090 let text = "Package: test\n";
5091 let d: Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822# = text.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().();
5092 let mut p = d.paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraphs().().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().();
5093
5094 // Rename to different case of the same name
5095 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(p.renamerust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]rename().("package", "PACKAGE"));
5096
5097 // The field name should now be uppercase
5098 let updated_text = d.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().();
5099 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(updated_text, "PACKAGE: test\n");
5100
5101 // Can still get with any case
5102 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(p.getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("package").as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("test"));
5103 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(p.getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("Package").as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("test"));
5104 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(p.getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("PACKAGE").as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("test"));
5105 }
5106
5107 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
5108 fn test_rename_preserves_indentation_and_whitespacerust-analyzer cargo deb822-lossless 0.5.18 lossless/test_rename_preserves_indentation_and_whitespace().() {
5109 // When renaming a field, the original post-colon whitespace and
5110 // continuation-line indentation must be preserved (only the key changes).
5111 let text =
5112 "Comments: Exceptions\n 1997-1999, 2003 MIT\n License terms\n";
5113 let d: Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822# = text.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().();
5114 let mut p = d.paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraphs().().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().();
5115
5116 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(p.renamerust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]rename().("Comments", "Comment"));
5117 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
5118 d.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(),
5119 "Comment: Exceptions\n 1997-1999, 2003 MIT\n License terms\n"
5120 );
5121 }
5122
5123 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
5124 fn test_rename_in_multi_field_paragraphrust-analyzer cargo deb822-lossless 0.5.18 lossless/test_rename_in_multi_field_paragraph().() {
5125 // Reproduce the intel-mkl scenario: Comments is the last of several
5126 // fields, with multi-line value containing internal indentation.
5127 let text = "Files: *\nCopyright: 2017 Foo\nLicense: GPL-2+\nComments: Exceptions\n There are many files in the .rpm archives.\n 1997-1999, 2003 MIT\n";
5128 let d: Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822# = text.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().();
5129 let mut p = d.paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraphs().().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().();
5130
5131 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(p.renamerust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]rename().("Comments", "Comment"));
5132 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(d.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), text.replacerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]replace().("Comments:", "Comment:"));
5133 }
5134
5135 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
5136 fn test_rename_preserves_post_colon_whitespacerust-analyzer cargo deb822-lossless 0.5.18 lossless/test_rename_preserves_post_colon_whitespace().() {
5137 // A single-line value with non-default post-colon whitespace must keep it.
5138 let text = "Files: install_GUI.sh\n";
5139 let d: Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822# = text.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().();
5140 let mut p = d.paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraphs().().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().();
5141
5142 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(p.renamerust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]rename().("Files", "File"));
5143 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(d.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "File: install_GUI.sh\n");
5144 }
5145
5146 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
5147 fn test_reject_whitespace_only_continuation_linerust-analyzer cargo deb822-lossless 0.5.18 lossless/test_reject_whitespace_only_continuation_line().() {
5148 // Issue #350: A continuation line with only whitespace should not be accepted
5149 // According to Debian Policy, continuation lines must have content after the leading space
5150 // A line with only whitespace (like " \n") should terminate the field
5151
5152 // This should be rejected/treated as an error
5153 let text = "Build-Depends:\n \ndebhelper\n";
5154 let parsed = Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#::parserust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]parse().(text);
5155
5156 // The empty line with just whitespace should cause an error
5157 // or at minimum, should not be included as part of the field value
5158 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(
5159 !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().parsed.errorsrust-analyzer cargo deb822-lossless 0.5.18 parse/impl#[`Parse<T>`]errors().().is_emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]is_empty().(),
5160 "Expected parse errors for whitespace-only continuation line"
5161 );
5162 }
5163
5164 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
5165 fn test_reject_empty_continuation_line_in_multiline_fieldrust-analyzer cargo deb822-lossless 0.5.18 lossless/test_reject_empty_continuation_line_in_multiline_field().() {
5166 // Test that an empty line terminates a multi-line field (and generates an error)
5167 let text = "Depends: foo,\n bar,\n \n baz\n";
5168 let parsed = Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#::parserust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]parse().(text);
5169
5170 // The empty line should cause parse errors
5171 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(
5172 !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().parsed.errorsrust-analyzer cargo deb822-lossless 0.5.18 parse/impl#[`Parse<T>`]errors().().is_emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]is_empty().(),
5173 "Empty continuation line should generate parse errors"
5174 );
5175
5176 // Verify we got the specific error about empty continuation line
5177 let has_empty_line_error = parsed
5178 .errorsrust-analyzer cargo deb822-lossless 0.5.18 parse/impl#[`Parse<T>`]errors().()
5179 .iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().()
5180 .anyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]any().(|e| e.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]contains().("empty continuation line"));
5181 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(
5182 has_empty_line_error,
5183 "Should have an error about empty continuation line"
5184 );
5185 }
5186
5187 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
5188 #[should_panic(expected = "empty continuation line")]
5189 fn test_set_rejects_empty_continuation_linesrust-analyzer cargo deb822-lossless 0.5.18 lossless/test_set_rejects_empty_continuation_lines().() {
5190 // Test that Paragraph.set() panics for values with empty continuation lines
5191 let text = "Package: test\n";
5192 let deb822 = text.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().::<Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#>().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
5193 let mut para = deb822.paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraphs().().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().();
5194
5195 // Try to set a field with an empty continuation line
5196 // This should panic with an appropriate error message
5197 let value_with_empty_line = "foo\n \nbar";
5198 para.setrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]set().("Depends", value_with_empty_line);
5199 }
5200
5201 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
5202 fn test_try_set_returns_error_for_empty_continuation_linesrust-analyzer cargo deb822-lossless 0.5.18 lossless/test_try_set_returns_error_for_empty_continuation_lines().() {
5203 // Test that Paragraph.try_set() returns an error for values with empty continuation lines
5204 let text = "Package: test\n";
5205 let deb822 = text.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().::<Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#>().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
5206 let mut para = deb822.paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraphs().().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().();
5207
5208 // Try to set a field with an empty continuation line
5209 let value_with_empty_line = "foo\n \nbar";
5210 let result = para.try_setrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]try_set().("Depends", value_with_empty_line);
5211
5212 // Should return an error
5213 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(
5214 result.is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().(),
5215 "try_set() should return an error for empty continuation lines"
5216 );
5217
5218 // Verify it's the right kind of error
5219 match result {
5220 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo deb822-lossless 0.5.18 lossless/Error#::InvalidValuerust-analyzer cargo deb822-lossless 0.5.18 lossless/Error#InvalidValue#(msg)) => {
5221 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(
5222 msg.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]contains().("empty continuation line"),
5223 "Error message should mention empty continuation line"
5224 );
5225 }
5226 _ => panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("Expected InvalidValue error"),
5227 }
5228 }
5229
5230 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
5231 fn test_try_set_with_indent_pattern_returns_errorrust-analyzer cargo deb822-lossless 0.5.18 lossless/test_try_set_with_indent_pattern_returns_error().() {
5232 // Test that try_set_with_indent_pattern() returns an error for empty continuation lines
5233 let text = "Package: test\n";
5234 let deb822 = text.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().::<Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#>().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
5235 let mut para = deb822.paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraphs().().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().();
5236
5237 let value_with_empty_line = "foo\n \nbar";
5238 let result = para.try_set_with_indent_patternrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]try_set_with_indent_pattern().(
5239 "Depends",
5240 value_with_empty_line,
5241 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&IndentPatternrust-analyzer cargo deb822-lossless 0.5.18 lossless/IndentPattern#::Fixedrust-analyzer cargo deb822-lossless 0.5.18 lossless/IndentPattern#Fixed#(2)),
5242 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
5243 );
5244
5245 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(
5246 result.is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().(),
5247 "try_set_with_indent_pattern() should return an error"
5248 );
5249 }
5250
5251 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
5252 fn test_try_set_succeeds_for_valid_valuerust-analyzer cargo deb822-lossless 0.5.18 lossless/test_try_set_succeeds_for_valid_value().() {
5253 // Test that try_set() succeeds for valid values
5254 let text = "Package: test\n";
5255 let deb822 = text.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().::<Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#>().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
5256 let mut para = deb822.paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraphs().().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().();
5257
5258 // Valid multiline value
5259 let valid_value = "foo\nbar";
5260 let result = para.try_setrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]try_set().("Depends", valid_value);
5261
5262 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(result.is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().(), "try_set() should succeed for valid values");
5263 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(para.getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("Depends").as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("foo\nbar"));
5264 }
5265
5266 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
5267 fn test_field_with_empty_first_linerust-analyzer cargo deb822-lossless 0.5.18 lossless/test_field_with_empty_first_line().() {
5268 // Test parsing a field where the value starts on a continuation line (empty first line)
5269 // This is valid according to Debian Policy - the first line can be empty
5270 let text = "Foo:\n blah\n blah\n";
5271 let parsed = Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#::parserust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]parse().(text);
5272
5273 // This should be valid - no errors
5274 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(
5275 parsed.errorsrust-analyzer cargo deb822-lossless 0.5.18 parse/impl#[`Parse<T>`]errors().().is_emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]is_empty().(),
5276 "Empty first line should be valid. Got errors: {:?}",
5277 parsed.errorsrust-analyzer cargo deb822-lossless 0.5.18 parse/impl#[`Parse<T>`]errors().()
5278 );
5279
5280 let deb822 = parsed.treerust-analyzer cargo deb822-lossless 0.5.18 parse/impl#[`Parse<T>`]tree().();
5281 let para = deb822.paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraphs().().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().();
5282 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(para.getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("Foo").as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("blah\nblah"));
5283 }
5284
5285 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
5286 fn test_try_set_with_empty_first_linerust-analyzer cargo deb822-lossless 0.5.18 lossless/test_try_set_with_empty_first_line().() {
5287 // Test that try_set() works with values that have empty first line
5288 let text = "Package: test\n";
5289 let deb822 = text.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().::<Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#>().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
5290 let mut para = deb822.paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraphs().().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().();
5291
5292 // Value with empty first line - this should be valid
5293 let value = "\nblah\nmore";
5294 let result = para.try_setrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]try_set().("Depends", value);
5295
5296 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(
5297 result.is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().(),
5298 "try_set() should succeed for values with empty first line. Got: {:?}",
5299 result
5300 );
5301 }
5302
5303 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
5304 fn test_field_with_value_then_empty_continuationrust-analyzer cargo deb822-lossless 0.5.18 lossless/test_field_with_value_then_empty_continuation().() {
5305 // Test that a field with a value on the first line followed by empty continuation is rejected
5306 let text = "Foo: bar\n \n";
5307 let parsed = Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#::parserust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]parse().(text);
5308
5309 // This should have errors - empty continuation line after initial value
5310 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(
5311 !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().parsed.errorsrust-analyzer cargo deb822-lossless 0.5.18 parse/impl#[`Parse<T>`]errors().().is_emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]is_empty().(),
5312 "Field with value then empty continuation line should be rejected"
5313 );
5314
5315 // Verify we got the specific error about empty continuation line
5316 let has_empty_line_error = parsed
5317 .errorsrust-analyzer cargo deb822-lossless 0.5.18 parse/impl#[`Parse<T>`]errors().()
5318 .iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().()
5319 .anyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]any().(|e| e.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]contains().("empty continuation line"));
5320 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(
5321 has_empty_line_error,
5322 "Should have error about empty continuation line"
5323 );
5324 }
5325
5326 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
5327 fn test_substvar_continuation_linerust-analyzer cargo deb822-lossless 0.5.18 lossless/test_substvar_continuation_line().() {
5328 let text = "\
5329 Package: python3-cryptography
5330 Architecture: any
5331 Depends: python3-bcrypt,
5332 ${misc:Depends},
5333 ${python3:Depends},
5334 ${shlibs:Depends},
5335 Suggests: python-cryptography-doc,
5336 python3-cryptography-vectors,
5337 Description: Python library exposing cryptographic recipes and primitives
5338 The cryptography library is designed to be a \"one-stop-shop\" for
5339 all your cryptographic needs in Python.
5340 .
5341 As an alternative to the libraries that came before it, cryptography
5342 tries to address some of the issues with those libraries:
5343 - Lack of PyPy and Python 3 support.
5344 - Lack of maintenance.
5345 - Use of poor implementations of algorithms (i.e. ones with known
5346 side-channel attacks).
5347 - Lack of high level, \"Cryptography for humans\", APIs.
5348 - Absence of algorithms such as AES-GCM.
5349 - Poor introspectability, and thus poor testability.
5350 - Extremely error prone APIs, and bad defaults.
5351 ";
5352 let parsed = Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#::parserust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]parse().(text);
5353 for e in parsed.positioned_errorsrust-analyzer cargo deb822-lossless 0.5.18 parse/impl#[`Parse<T>`]positioned_errors().() {
5354 eprintlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/eprintln!!("error at {:?}: {}", e.rangerust-analyzer cargo deb822-lossless 0.5.18 lossless/PositionedParseError#range., e.messagerust-analyzer cargo deb822-lossless 0.5.18 lossless/PositionedParseError#message.);
5355 }
5356 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(
5357 parsed.errorsrust-analyzer cargo deb822-lossless 0.5.18 parse/impl#[`Parse<T>`]errors().().is_emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]is_empty().(),
5358 "Should not produce errors: {:?}",
5359 parsed.errorsrust-analyzer cargo deb822-lossless 0.5.18 parse/impl#[`Parse<T>`]errors().()
5360 );
5361 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(
5362 parsed.positioned_errorsrust-analyzer cargo deb822-lossless 0.5.18 parse/impl#[`Parse<T>`]positioned_errors().().is_emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]is_empty().(),
5363 "Should not produce positioned errors: {:?}",
5364 parsed.positioned_errorsrust-analyzer cargo deb822-lossless 0.5.18 parse/impl#[`Parse<T>`]positioned_errors().()
5365 );
5366 }
5367
5368 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
5369 fn test_line_colrust-analyzer cargo deb822-lossless 0.5.18 lossless/test_line_col().() {
5370 let text = r#"Source: foo
5371 Maintainer: Foo Bar <[email protected]>
5372 Section: net
5373
5374 Package: foo
5375 Architecture: all
5376 Depends: libc6
5377 Description: This is a description
5378 With details
5379 "#;
5380 let deb822 = text.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().::<Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#>().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
5381
5382 // Test paragraph line numbers
5383 let paras: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_> = deb822.paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraphs().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().();
5384 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(paras.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 2);
5385
5386 // First paragraph starts at line 0
5387 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(paras[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()..linerust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]line().(), 0);
5388 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(paras[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()..columnrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]column().(), 0);
5389
5390 // Second paragraph starts at line 4 (after the empty line)
5391 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(paras[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().1]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()..linerust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]line().(), 4);
5392 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(paras[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().1]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()..columnrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]column().(), 0);
5393
5394 // Test entry line numbers
5395 let entries: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_> = paras[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()..entriesrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]entries().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().();
5396 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(entries[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()..linerust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]line().(), 0); // Source: foo
5397 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(entries[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().1]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()..linerust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]line().(), 1); // Maintainer: ...
5398 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(entries[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().2]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()..linerust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]line().(), 2); // Section: net
5399
5400 // Test column numbers
5401 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(entries[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()..columnrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]column().(), 0); // Start of line
5402 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(entries[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().1]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()..columnrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]column().(), 0); // Start of line
5403
5404 // Test line_col() method
5405 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(paras[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().1]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()..line_colrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]line_col().(), (4, 0));
5406 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(entries[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()..line_colrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]line_col().(), (0, 0));
5407
5408 // Test multi-line entry
5409 let second_para_entries: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_> = paras[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().1]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()..entriesrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]entries().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().();
5410 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(second_para_entries[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().3]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()..linerust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]line().(), 7); // Description starts at line 7
5411 }
5412
5413 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
5414 fn test_deb822_snapshot_independencerust-analyzer cargo deb822-lossless 0.5.18 lossless/test_deb822_snapshot_independence().() {
5415 let text = r#"Source: foo
5416 Maintainer: Joe <[email protected]>
5417
5418 Package: foo
5419 Architecture: all
5420 "#;
5421 let deb822 = text.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().::<Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#>().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
5422 let snap = deb822.snapshotrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]snapshot().();
5423 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(deb822.tree_eqrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]tree_eq().(&snap));
5424
5425 let mut para = deb822.paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraphs().().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().();
5426 para.setrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]set().("Source", "modified");
5427
5428 // snapshot unchanged
5429 let snap_para = snap.paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraphs().().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().();
5430 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(snap_para.getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("Source").as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("foo"));
5431 // ... and now they have diverged
5432 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().deb822.tree_eqrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]tree_eq().(&snap));
5433 }
5434
5435 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
5436 fn test_paragraph_snapshot_independencerust-analyzer cargo deb822-lossless 0.5.18 lossless/test_paragraph_snapshot_independence().() {
5437 let text = "Package: foo\nArchitecture: all\n";
5438 let deb822 = text.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().::<Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#>().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
5439 let mut para = deb822.paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraphs().().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().();
5440 let snap = para.snapshotrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]snapshot().();
5441 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(para.tree_eqrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]tree_eq().(&snap));
5442
5443 para.setrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]set().("Package", "modified");
5444 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(snap.getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("Package").as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("foo"));
5445 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().para.tree_eqrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]tree_eq().(&snap));
5446 }
5447
5448 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
5449 fn test_tree_eq_value_equivalencerust-analyzer cargo deb822-lossless 0.5.18 lossless/test_tree_eq_value_equivalence().() {
5450 // Two independently-parsed trees with identical content should be tree_eq
5451 // (no shared green pointer, but structural equality holds).
5452 let text = "Package: foo\nArchitecture: all\n";
5453 let a = text.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().::<Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#>().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
5454 let b = text.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().::<Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#>().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
5455 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(a.tree_eqrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]tree_eq().(&b));
5456 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(b.tree_eqrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]tree_eq().(&a));
5457
5458 // Different content => not tree_eq.
5459 let c: Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822# = "Package: bar\n".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().();
5460 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().a.tree_eqrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]tree_eq().(&c));
5461 }
5462
5463 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
5464 fn test_entry_snapshot_independencerust-analyzer cargo deb822-lossless 0.5.18 lossless/test_entry_snapshot_independence().() {
5465 let text = "Package: foo\n";
5466 let deb822 = text.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().::<Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#>().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
5467 let mut para = deb822.paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraphs().().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().();
5468 let entry = para.entriesrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]entries().().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().();
5469 let snap = entry.snapshotrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]snapshot().();
5470 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(entry.tree_eqrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]tree_eq().(&snap));
5471
5472 para.setrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]set().("Package", "modified");
5473 // The snapshot entry points to an independent tree
5474 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(snap.valuerust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]value().(), "foo");
5475 }
5476
5477 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
5478 fn test_paragraph_text_rangerust-analyzer cargo deb822-lossless 0.5.18 lossless/test_paragraph_text_range().() {
5479 // Test that text_range() returns the correct range for a paragraph
5480 let text = r#"Source: foo
5481 Maintainer: Joe <[email protected]>
5482
5483 Package: foo
5484 Architecture: all
5485 "#;
5486 let deb822 = text.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().::<Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#>().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
5487 let paras: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_> = deb822.paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraphs().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().();
5488
5489 // First paragraph
5490 let range1 = paras[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()..text_rangerust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]text_range().();
5491 let para1_text = &text[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().range1.startrust-analyzer cargo text-size 1.1.1 range/impl#[TextRange]start().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#range1.endrust-analyzer cargo text-size 1.1.1 range/impl#[TextRange]end().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().;
5492 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
5493 para1_text,
5494 "Source: foo\nMaintainer: Joe <[email protected]>\n"
5495 );
5496
5497 // Second paragraph
5498 let range2 = paras[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().1]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()..text_rangerust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]text_range().();
5499 let para2_text = &text[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().range2.startrust-analyzer cargo text-size 1.1.1 range/impl#[TextRange]start().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#range2.endrust-analyzer cargo text-size 1.1.1 range/impl#[TextRange]end().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().;
5500 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(para2_text, "Package: foo\nArchitecture: all\n");
5501 }
5502
5503 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
5504 fn test_paragraphs_in_range_singlerust-analyzer cargo deb822-lossless 0.5.18 lossless/test_paragraphs_in_range_single().() {
5505 // Test finding a single paragraph in range
5506 let text = r#"Source: foo
5507
5508 Package: bar
5509
5510 Package: baz
5511 "#;
5512 let deb822 = text.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().::<Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#>().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
5513
5514 // Get range of first paragraph
5515 let first_para = deb822.paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraphs().().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().();
5516 let range = first_para.text_rangerust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]text_range().();
5517
5518 // Query paragraphs in that range
5519 let paras: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_> = deb822.paragraphs_in_rangerust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraphs_in_range().(range).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().();
5520 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(paras.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 1);
5521 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(paras[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()..getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("Source").as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("foo"));
5522 }
5523
5524 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
5525 fn test_paragraphs_in_range_multiplerust-analyzer cargo deb822-lossless 0.5.18 lossless/test_paragraphs_in_range_multiple().() {
5526 // Test finding multiple paragraphs in range
5527 let text = r#"Source: foo
5528
5529 Package: bar
5530
5531 Package: baz
5532 "#;
5533 let deb822 = text.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().::<Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#>().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
5534
5535 // Create a range that covers first two paragraphs
5536 let range = rowanrust-analyzer cargo rowan 0.16.1 crate/::TextRangerust-analyzer cargo text-size 1.1.1 range/TextRange#::newrust-analyzer cargo text-size 1.1.1 range/impl#[TextRange]new().(0.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), 25.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
5537
5538 // Query paragraphs in that range
5539 let paras: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_> = deb822.paragraphs_in_rangerust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraphs_in_range().(range).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().();
5540 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(paras.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 2);
5541 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(paras[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()..getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("Source").as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("foo"));
5542 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(paras[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().1]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()..getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("Package").as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("bar"));
5543 }
5544
5545 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
5546 fn test_paragraphs_in_range_partial_overlaprust-analyzer cargo deb822-lossless 0.5.18 lossless/test_paragraphs_in_range_partial_overlap().() {
5547 // Test that paragraphs are included if they partially overlap with the range
5548 let text = r#"Source: foo
5549
5550 Package: bar
5551
5552 Package: baz
5553 "#;
5554 let deb822 = text.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().::<Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#>().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
5555
5556 // Create a range that starts in the middle of the second paragraph
5557 let range = rowanrust-analyzer cargo rowan 0.16.1 crate/::TextRangerust-analyzer cargo text-size 1.1.1 range/TextRange#::newrust-analyzer cargo text-size 1.1.1 range/impl#[TextRange]new().(15.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), 30.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
5558
5559 // Should include the second paragraph since it overlaps
5560 let paras: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_> = deb822.paragraphs_in_rangerust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraphs_in_range().(range).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().();
5561 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(paras.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().() >= 1);
5562 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(paras
5563 .iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().()
5564 .anyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]any().(|p| p.getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("Package").as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().() == Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("bar")));
5565 }
5566
5567 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
5568 fn test_paragraphs_in_range_no_matchrust-analyzer cargo deb822-lossless 0.5.18 lossless/test_paragraphs_in_range_no_match().() {
5569 // Test that empty iterator is returned when no paragraphs are in range
5570 let text = r#"Source: foo
5571
5572 Package: bar
5573 "#;
5574 let deb822 = text.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().::<Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#>().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
5575
5576 // Create a range that's way beyond the document
5577 let range = rowanrust-analyzer cargo rowan 0.16.1 crate/::TextRangerust-analyzer cargo text-size 1.1.1 range/TextRange#::newrust-analyzer cargo text-size 1.1.1 range/impl#[TextRange]new().(1000.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), 2000.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
5578
5579 // Should return empty iterator
5580 let paras: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_> = deb822.paragraphs_in_rangerust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraphs_in_range().(range).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().();
5581 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(paras.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 0);
5582 }
5583
5584 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
5585 fn test_paragraphs_in_range_allrust-analyzer cargo deb822-lossless 0.5.18 lossless/test_paragraphs_in_range_all().() {
5586 // Test finding all paragraphs when range covers entire document
5587 let text = r#"Source: foo
5588
5589 Package: bar
5590
5591 Package: baz
5592 "#;
5593 let deb822 = text.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().::<Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#>().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
5594
5595 // Create a range that covers the entire document
5596 let range = rowanrust-analyzer cargo rowan 0.16.1 crate/::TextRangerust-analyzer cargo text-size 1.1.1 range/TextRange#::newrust-analyzer cargo text-size 1.1.1 range/impl#[TextRange]new().(0.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), text.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]len().().try_intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`TryInto<U>`]try_into().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().());
5597
5598 // Should return all paragraphs
5599 let paras: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_> = deb822.paragraphs_in_rangerust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraphs_in_range().(range).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().();
5600 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(paras.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 3);
5601 }
5602
5603 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
5604 fn test_paragraph_at_positionrust-analyzer cargo deb822-lossless 0.5.18 lossless/test_paragraph_at_position().() {
5605 // Test finding paragraph at a given text offset
5606 let text = r#"Package: foo
5607 Version: 1.0
5608
5609 Package: bar
5610 Architecture: all
5611 "#;
5612 let deb822 = text.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().::<Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#>().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
5613
5614 // Position 5 is within first paragraph ("Package: foo")
5615 let para = deb822.paragraph_at_positionrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraph_at_position().(rowanrust-analyzer cargo rowan 0.16.1 crate/::TextSizerust-analyzer cargo text-size 1.1.1 size/TextSize#::fromrust-analyzer cargo text-size 1.1.1 size/impl#[TextSize][`From<u32>`]from().(5));
5616 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(para.is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().());
5617 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(para.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("Package").as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("foo"));
5618
5619 // Position 30 is within second paragraph
5620 let para = deb822.paragraph_at_positionrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraph_at_position().(rowanrust-analyzer cargo rowan 0.16.1 crate/::TextSizerust-analyzer cargo text-size 1.1.1 size/TextSize#::fromrust-analyzer cargo text-size 1.1.1 size/impl#[TextSize][`From<u32>`]from().(30));
5621 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(para.is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().());
5622 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(para.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("Package").as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("bar"));
5623
5624 // Position beyond document
5625 let para = deb822.paragraph_at_positionrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraph_at_position().(rowanrust-analyzer cargo rowan 0.16.1 crate/::TextSizerust-analyzer cargo text-size 1.1.1 size/TextSize#::fromrust-analyzer cargo text-size 1.1.1 size/impl#[TextSize][`From<u32>`]from().(1000));
5626 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(para.is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().());
5627 }
5628
5629 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
5630 fn test_paragraph_at_linerust-analyzer cargo deb822-lossless 0.5.18 lossless/test_paragraph_at_line().() {
5631 // Test finding paragraph at a given line number
5632 let text = r#"Package: foo
5633 Version: 1.0
5634
5635 Package: bar
5636 Architecture: all
5637 "#;
5638 let deb822 = text.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().::<Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#>().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
5639
5640 // Line 0 is in first paragraph
5641 let para = deb822.paragraph_at_linerust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraph_at_line().(0);
5642 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(para.is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().());
5643 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(para.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("Package").as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("foo"));
5644
5645 // Line 1 is also in first paragraph
5646 let para = deb822.paragraph_at_linerust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraph_at_line().(1);
5647 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(para.is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().());
5648 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(para.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("Package").as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("foo"));
5649
5650 // Line 3 is in second paragraph
5651 let para = deb822.paragraph_at_linerust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraph_at_line().(3);
5652 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(para.is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().());
5653 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(para.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("Package").as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("bar"));
5654
5655 // Line beyond document
5656 let para = deb822.paragraph_at_linerust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraph_at_line().(100);
5657 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(para.is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().());
5658 }
5659
5660 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
5661 fn test_entry_at_line_colrust-analyzer cargo deb822-lossless 0.5.18 lossless/test_entry_at_line_col().() {
5662 // Test finding entry at a given line/column position
5663 let text = r#"Package: foo
5664 Version: 1.0
5665 Architecture: all
5666 "#;
5667 let deb822 = text.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().::<Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#>().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
5668
5669 // Line 0, column 0 is in "Package: foo"
5670 let entry = deb822.entry_at_line_colrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]entry_at_line_col().(0, 0);
5671 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(entry.is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().());
5672 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(entry.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().keyrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]key().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("Package".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()));
5673
5674 // Line 1, column 0 is in "Version: 1.0"
5675 let entry = deb822.entry_at_line_colrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]entry_at_line_col().(1, 0);
5676 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(entry.is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().());
5677 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(entry.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().keyrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]key().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("Version".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()));
5678
5679 // Line 2, column 5 is in "Architecture: all"
5680 let entry = deb822.entry_at_line_colrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]entry_at_line_col().(2, 5);
5681 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(entry.is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().());
5682 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(entry.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().keyrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]key().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("Architecture".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()));
5683
5684 // Position beyond document
5685 let entry = deb822.entry_at_line_colrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]entry_at_line_col().(100, 0);
5686 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(entry.is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().());
5687 }
5688
5689 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
5690 fn test_entry_at_line_col_multilinerust-analyzer cargo deb822-lossless 0.5.18 lossless/test_entry_at_line_col_multiline().() {
5691 // Test finding entry in a multiline value
5692 let text = r#"Package: foo
5693 Description: A package
5694 with a long
5695 description
5696 Version: 1.0
5697 "#;
5698 let deb822 = text.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().::<Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#>().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
5699
5700 // Line 1 is the start of Description
5701 let entry = deb822.entry_at_line_colrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]entry_at_line_col().(1, 0);
5702 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(entry.is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().());
5703 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(entry.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().keyrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]key().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("Description".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()));
5704
5705 // Line 2 is continuation of Description
5706 let entry = deb822.entry_at_line_colrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]entry_at_line_col().(2, 1);
5707 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(entry.is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().());
5708 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(entry.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().keyrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]key().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("Description".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()));
5709
5710 // Line 3 is also continuation of Description
5711 let entry = deb822.entry_at_line_colrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]entry_at_line_col().(3, 1);
5712 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(entry.is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().());
5713 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(entry.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().keyrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]key().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("Description".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()));
5714
5715 // Line 4 is Version
5716 let entry = deb822.entry_at_line_colrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]entry_at_line_col().(4, 0);
5717 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(entry.is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().());
5718 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(entry.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().keyrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]key().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("Version".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()));
5719 }
5720
5721 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
5722 fn test_entries_in_rangerust-analyzer cargo deb822-lossless 0.5.18 lossless/test_entries_in_range().() {
5723 // Test finding entries in a paragraph within a range
5724 let text = r#"Package: foo
5725 Version: 1.0
5726 Architecture: all
5727 "#;
5728 let deb822 = text.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().::<Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#>().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
5729 let para = deb822.paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraphs().().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().();
5730
5731 // Get first entry's range
5732 let first_entry = para.entriesrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]entries().().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().();
5733 let range = first_entry.text_rangerust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]text_range().();
5734
5735 // Query entries in that range - should get only first entry
5736 let entries: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_> = para.entries_in_rangerust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]entries_in_range().(range).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().();
5737 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(entries.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 1);
5738 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(entries[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()..keyrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]key().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("Package".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()));
5739
5740 // Query with a range covering first two entries
5741 let range = rowanrust-analyzer cargo rowan 0.16.1 crate/::TextRangerust-analyzer cargo text-size 1.1.1 range/TextRange#::newrust-analyzer cargo text-size 1.1.1 range/impl#[TextRange]new().(0.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), 25.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
5742 let entries: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_> = para.entries_in_rangerust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]entries_in_range().(range).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().();
5743 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(entries.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 2);
5744 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(entries[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()..keyrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]key().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("Package".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()));
5745 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(entries[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().1]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()..keyrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]key().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("Version".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()));
5746 }
5747
5748 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
5749 fn test_entries_in_range_partial_overlaprust-analyzer cargo deb822-lossless 0.5.18 lossless/test_entries_in_range_partial_overlap().() {
5750 // Test that entries with partial overlap are included
5751 let text = r#"Package: foo
5752 Version: 1.0
5753 Architecture: all
5754 "#;
5755 let deb822 = text.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().::<Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#>().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
5756 let para = deb822.paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraphs().().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().();
5757
5758 // Create a range that starts in the middle of the second entry
5759 let range = rowanrust-analyzer cargo rowan 0.16.1 crate/::TextRangerust-analyzer cargo text-size 1.1.1 range/TextRange#::newrust-analyzer cargo text-size 1.1.1 range/impl#[TextRange]new().(15.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), 30.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
5760
5761 let entries: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_> = para.entries_in_rangerust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]entries_in_range().(range).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().();
5762 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(entries.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().() >= 1);
5763 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(entries
5764 .iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().()
5765 .anyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]any().(|e| e.keyrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]key().() == Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("Version".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())));
5766 }
5767
5768 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
5769 fn test_entries_in_range_no_matchrust-analyzer cargo deb822-lossless 0.5.18 lossless/test_entries_in_range_no_match().() {
5770 // Test that empty iterator is returned when no entries match
5771 let text = "Package: foo\n";
5772 let deb822 = text.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().::<Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#>().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
5773 let para = deb822.paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraphs().().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().();
5774
5775 // Range beyond the paragraph
5776 let range = rowanrust-analyzer cargo rowan 0.16.1 crate/::TextRangerust-analyzer cargo text-size 1.1.1 range/TextRange#::newrust-analyzer cargo text-size 1.1.1 range/impl#[TextRange]new().(1000.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), 2000.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
5777 let entries: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_> = para.entries_in_rangerust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]entries_in_range().(range).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().();
5778 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(entries.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 0);
5779 }
5780
5781 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
5782 fn test_entry_at_positionrust-analyzer cargo deb822-lossless 0.5.18 lossless/test_entry_at_position().() {
5783 // Test finding entry at a specific text offset
5784 let text = r#"Package: foo
5785 Version: 1.0
5786 Architecture: all
5787 "#;
5788 let deb822 = text.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().::<Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#>().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
5789 let para = deb822.paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraphs().().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().();
5790
5791 // Position 5 is within "Package: foo"
5792 let entry = para.entry_at_positionrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]entry_at_position().(rowanrust-analyzer cargo rowan 0.16.1 crate/::TextSizerust-analyzer cargo text-size 1.1.1 size/TextSize#::fromrust-analyzer cargo text-size 1.1.1 size/impl#[TextSize][`From<u32>`]from().(5));
5793 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(entry.is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().());
5794 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(entry.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().keyrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]key().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("Package".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()));
5795
5796 // Position 15 is within "Version: 1.0"
5797 let entry = para.entry_at_positionrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]entry_at_position().(rowanrust-analyzer cargo rowan 0.16.1 crate/::TextSizerust-analyzer cargo text-size 1.1.1 size/TextSize#::fromrust-analyzer cargo text-size 1.1.1 size/impl#[TextSize][`From<u32>`]from().(15));
5798 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(entry.is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().());
5799 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(entry.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().keyrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]key().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("Version".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()));
5800
5801 // Position beyond paragraph
5802 let entry = para.entry_at_positionrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]entry_at_position().(rowanrust-analyzer cargo rowan 0.16.1 crate/::TextSizerust-analyzer cargo text-size 1.1.1 size/TextSize#::fromrust-analyzer cargo text-size 1.1.1 size/impl#[TextSize][`From<u32>`]from().(1000));
5803 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(entry.is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().());
5804 }
5805
5806 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
5807 fn test_entry_at_position_multilinerust-analyzer cargo deb822-lossless 0.5.18 lossless/test_entry_at_position_multiline().() {
5808 // Test finding entry in a multiline value
5809 let text = r#"Description: A package
5810 with a long
5811 description
5812 "#;
5813 let deb822 = text.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().::<Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#>().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
5814 let para = deb822.paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraphs().().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().();
5815
5816 // Position 5 is within the Description entry
5817 let entry = para.entry_at_positionrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]entry_at_position().(rowanrust-analyzer cargo rowan 0.16.1 crate/::TextSizerust-analyzer cargo text-size 1.1.1 size/TextSize#::fromrust-analyzer cargo text-size 1.1.1 size/impl#[TextSize][`From<u32>`]from().(5));
5818 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(entry.is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().());
5819 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(entry.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().keyrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]key().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("Description".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()));
5820
5821 // Position in continuation line should also find the Description entry
5822 let entry = para.entry_at_positionrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]entry_at_position().(rowanrust-analyzer cargo rowan 0.16.1 crate/::TextSizerust-analyzer cargo text-size 1.1.1 size/TextSize#::fromrust-analyzer cargo text-size 1.1.1 size/impl#[TextSize][`From<u32>`]from().(30));
5823 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(entry.is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().());
5824 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(entry.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().keyrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Entry]key().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("Description".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()));
5825 }
5826
5827 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
5828 fn test_paragraph_at_position_at_boundaryrust-analyzer cargo deb822-lossless 0.5.18 lossless/test_paragraph_at_position_at_boundary().() {
5829 // Test paragraph_at_position at paragraph boundaries
5830 let text = "Package: foo\n\nPackage: bar\n";
5831 let deb822 = text.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().::<Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#>().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
5832
5833 // Position 0 is start of first paragraph
5834 let para = deb822.paragraph_at_positionrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraph_at_position().(rowanrust-analyzer cargo rowan 0.16.1 crate/::TextSizerust-analyzer cargo text-size 1.1.1 size/TextSize#::fromrust-analyzer cargo text-size 1.1.1 size/impl#[TextSize][`From<u32>`]from().(0));
5835 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(para.is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().());
5836 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(para.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("Package").as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("foo"));
5837
5838 // Position at start of second paragraph
5839 let para = deb822.paragraph_at_positionrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraph_at_position().(rowanrust-analyzer cargo rowan 0.16.1 crate/::TextSizerust-analyzer cargo text-size 1.1.1 size/TextSize#::fromrust-analyzer cargo text-size 1.1.1 size/impl#[TextSize][`From<u32>`]from().(15));
5840 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(para.is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().());
5841 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(para.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("Package").as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("bar"));
5842 }
5843
5844 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
5845 fn test_comment_in_multiline_valuerust-analyzer cargo deb822-lossless 0.5.18 lossless/test_comment_in_multiline_value().() {
5846 // Commented-out continuation lines within a multi-line field value
5847 // should be preserved losslessly and not cause parse errors.
5848 let text = "\
5849 Build-Depends: dh-python,
5850 libsvn-dev,
5851 # python-all-dbg (>= 2.6.6-3),
5852 python3-all-dev,
5853 # python3-all-dbg,
5854 python3-docutils
5855 Standards-Version: 4.7.0
5856 ";
5857 let deb822 = text.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().::<Deb822rust-analyzer cargo deb822-lossless 0.5.18 lossless/Deb822#>().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
5858 let para = deb822.paragraphsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Deb822]paragraphs().().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().();
5859 // get() returns the value without comments
5860 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
5861 para.getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("Build-Depends").as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(),
5862 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("dh-python,\nlibsvn-dev,\npython3-all-dev,\npython3-docutils")
5863 );
5864 // get_with_comments() / value_with_comments() includes the comment lines
5865 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
5866 para.get_with_commentsrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get_with_comments().("Build-Depends").as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(),
5867 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("dh-python,\nlibsvn-dev,\n# python-all-dbg (>= 2.6.6-3),\npython3-all-dev,\n# python3-all-dbg,\npython3-docutils")
5868 );
5869 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(para.getrust-analyzer cargo deb822-lossless 0.5.18 lossless/impl#[Paragraph]get().("Standards-Version").as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("4.7.0"));
5870 // Round-trip
5871 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(deb822.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), text);
5872 }