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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
//! # wip -- The crate you'll never put into production
//!
//! `wip` helps you during Rust development by helping signal when something
//! is unfinished.
//!
//! It plays a role similar to the [`std::todo`] macro, but emits warning on use,
//! so that a proper CI blocks uses of this crate from reaching production.
//!
//! 
//!
//! # What's inside?
//!
//! - `wip` extension methods for [`Result`] and [`Option`] via [`WipResultExt::wip`] and [`WipOptionExt::wip`].
//! They function like `unwrap` but emit warnings on use, so that you remember to remove them before merging that PR!
//! - `clone_fixme` extension method for any clonable object, for clones that you might later regret, via [`WipCloneExt::clone_fixme`].
//! - `wip!()` macros that emit warnings ([`wip!`]) and work with iterators ([`wip_iter!`]) and futures ([`wip_future!`], you guessed it)
//! - A `fixme()` macro that doesn't panic like [`wip!`], but still emit a warning, to keep track of all these `// FIXME: handle edge case` in your code...
//!
//! # How to use?
//!
//! 1. Add the crate to your dependencies.
//! 2. (optional)
//! glob import the prelude in your files: `use wip::prelude::*;`
//! with the one from this crate.
//! 3. Profit!
//!
//! This crate relies on deprecation warnings, so make sure you don't `#![allow(deprecated)]`,
//! lest it won't warn you as intended.
//!
//! # Alternatives
//!
//! I don't currently know of crates exposing the same functionality.
//! However, if you don't like the idea of adding a dependency for this,
//! did you know you could use doc comments over expressions to benefit from a free warning?
//!
//! ```norust
//! unused doc comment
//! use `//` for a plain comment
//! `#[warn(unused_doc_comments)]` on by default
//! ```
//!
//! # No genAI
//!
//! This crate does not use any genAI tooling and intends on staying so.
use Debug;
/// Extension trait for [`std::result::Result`] to expose the [`WipResultExt::wip`] method.
/// Extension trait for [`std::option::Option`] to expose the [`WipOptionExt::wip`] method.
/// Extension trait for any clonable `T` to expose the [`WipCloneExt::clone_fixme`] method.
/// Indicates unfinished code, emits a deprecation warning, and **panics** if reached.
///
/// This can be useful if you are prototyping and just want a placeholder to let your code pass type analysis.
///
/// Similar to [`std::todo`], but emits a warning on use.
/// Indicates unfinished code, emits a deprecation warning, but **does not** panic if reached.
///
/// This macro is useful as a quick note that something must be fixed before hitting production,
/// but no panic is necessary.
///
/// ```
/// wip::fixme!("handle edge case where i == j");
/// ```
/// Indicates unfinished code, emits a deprecation warning, **panics** if reached, works for `impl Iterator`.
///
/// Regular [`wip`] does not work for iterators, because `!` does not implement `Iterator`.
///
/// # Examples
///
/// Use when Rust cannot infer the concrete type of an iterator you didn't write yet:
///
/// ```
/// fn my_unfinished_iterator() -> impl Iterator<Item=usize> {
/// wip::wip_iter!()
/// }
/// ```
///
/// Otherwise, you can use the regular [`wip`].
///
/// ## Another branch specifies the type
/// ```
/// fn my_unfinished_iterator() -> impl Iterator<Item=usize> {
/// if true {
/// [0, 1, 2].iter().map(|x| x*2)
/// } else {
/// wip::wip!()
/// }
/// }
/// ```
///
/// ## Specific return type expected
///
/// ```
/// fn my_unfinished_iterator() -> std::iter::Once<usize> {
/// wip::wip!()
/// }
/// ```
/// Indicates unfinished code, emits a deprecation warning, **panics** if reached, works for `impl Future`.
///
/// Regular [`wip`] does not work for futures, because `!` does not implement `Future`.
///
/// # Examples
///
/// Use when Rust cannot infer the concrete type of a future you didn't write yet:
///
/// ```
/// fn my_unfinished_future() -> impl Future<Output=usize> {
/// wip::wip_future!()
/// }
/// ```
///
/// Otherwise, you can use the regular [`wip`].
///
/// ## Another branch specifies the type
/// ```
/// fn my_unfinished_future() -> impl Future<Output=usize> {
/// if true {
/// std::future::ready(42)
/// } else {
/// wip::wip!()
/// }
/// }
/// ```
///
/// ## Specific return type expected
///
/// ```
/// fn my_unfinished_future() -> std::future::Ready<usize> {
/// wip::wip!()
/// }
/// ```
/// Prelude to glob import for easy use of the provided functions and extension traits.
///
/// # Example
///
/// ```
/// use wip::prelude::*;
///
/// fn test() {
/// None.wip()
/// }
/// ```