1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/// Creates a vector by converting each element with [`Into::into`].
///
/// The target element type must be known from a type annotation or the receiving API.
/// For Lucene fields, queries and sort fields, prefer [`fields!`](crate::fields!),
/// [`queries!`](crate::queries!) and [`sort_fields!`](crate::sort_fields!), which also
/// infer the target type for empty lists.
///
/// ```
/// let values: Vec<String> = rlucene::into_vec!["first", String::from("second")];
/// assert_eq!(values, ["first", "second"]);
/// ```
/// Creates a `Vec<Fields>` from different concrete field types without explicit conversions.
///
/// Each expression is evaluated once, in order, and moved into the vector. The empty
/// invocation `fields![]` also has the concrete type `Vec<Fields>`.
///
/// ```
/// use rlucene::core::document::{field::Store, int_field::IntField, text_field::TextField};
/// # use rlucene::core::util::error::lucene_error::Result;
/// # fn main() -> Result<()> {
/// let fields = rlucene::fields![
/// IntField::new("age", 18, Store::Yes)?,
/// TextField::from_string("body", "Rust Lucene", Store::No)?,
/// ];
/// # assert_eq!(fields.len(), 2);
/// # Ok(())
/// # }
/// ```
/// Creates a `Vec<Query>` from different query types using Lucene's [`IntoQuery`](crate::core::search::query::IntoQuery).
///
/// Each expression is evaluated once, in order. The empty invocation `queries![]`
/// also has the concrete type `Vec<Query>`.
///
/// ```
/// use rlucene::core::index::term::Term;
/// use rlucene::core::search::{match_all_docs_query::MatchAllDocsQuery, term_query::TermQuery};
/// let queries = rlucene::queries![
/// TermQuery::new(Term::from_text("id", "42")),
/// MatchAllDocsQuery::new(),
/// ];
/// assert_eq!(queries.len(), 2);
/// ```
/// Creates a `Vec<SortFieldEnum>` from different concrete sort field types.
///
/// Each expression is evaluated once, in order. The empty invocation `sort_fields![]`
/// has the concrete type `Vec<SortFieldEnum>`; [`Sort::with_fields`](crate::core::search::sort::Sort::with_fields)
/// still rejects an empty collection.
///
/// ```
/// use rlucene::core::search::sort::Sort;
/// use rlucene::core::search::sort_field::{SortField, SortFieldType};
/// use rlucene::core::search::sorted_numeric_sort_field::SortedNumericSortField;
/// # use rlucene::core::util::error::lucene_error::Result;
/// # fn main() -> Result<()> {
/// let sort = Sort::with_fields(rlucene::sort_fields![
/// SortedNumericSortField::new("age", SortFieldType::Int)?,
/// SortField::get_field_doc()?,
/// ])?;
/// # assert_eq!(sort.get_sort().len(), 2);
/// # Ok(())
/// # }
/// ```
/// Extracts a value whose presence or success is guaranteed by a documented program invariant.
///
/// Production code must use this macro instead of calling `Option::expect` or `Result::expect`
/// directly. The reason must describe why failure is a programmer error rather than a recoverable
/// runtime condition.
/// Panics for a documented, unrecoverable program invariant violation.
///
/// Production code must use this macro instead of calling `panic!` directly. The literal reason
/// must explain why the failure is a programmer error rather than a recoverable runtime condition.
/// The reason documents the lint exemption; the panic message is preserved without a prefix.
/// Declares a mutable slice backed by a local array or, for larger lengths, a vector.
///
/// Usage: `stack_or_heap_buffer!(name, element_type, length, stack_capacity, initial_value);`
/// The element type must be `Copy`; stack capacity is a compile-time element count,
/// not a byte budget. Length and initial value are each evaluated once.
///
/// Expands into declarations in the caller's scope so both backing buffers outlive the
/// slice. The fixed array can occupy stack space even when the heap branch is selected;
/// callers must account for nested calls and recursion when choosing its capacity.