File tree 1 file changed +45
-0
lines changed
1 file changed +45
-0
lines changed Original file line number Diff line number Diff line change @@ -254,6 +254,51 @@ macro_rules! unreachable {
254
254
255
255
/// A standardised placeholder for marking unfinished code. It panics with the
256
256
/// message `"not yet implemented"` when executed.
257
+ ///
258
+ /// This can be useful if you are prototyping and are just looking to have your
259
+ /// code typecheck, or if you're implementing a trait that requires multiple
260
+ /// methods, and you're only planning on using one of them.
261
+ ///
262
+ /// # Examples
263
+ ///
264
+ /// Here's an example of some in-progress code. We have a trait `Foo`:
265
+ ///
266
+ /// ```
267
+ /// trait Foo {
268
+ /// fn bar(&self);
269
+ /// fn baz(&self);
270
+ /// }
271
+ /// ```
272
+ ///
273
+ /// We want to implement `Foo` on one of our types, but we also want to work on
274
+ /// just `bar()` first. In order for our code to compile, we need to implement
275
+ /// `baz()`, so we can use `unimplemented!`:
276
+ ///
277
+ /// ```
278
+ /// # trait Foo {
279
+ /// # fn foo(&self);
280
+ /// # fn bar(&self);
281
+ /// # }
282
+ /// struct MyStruct;
283
+ ///
284
+ /// impl Foo for MyStruct {
285
+ /// fn foo(&self) {
286
+ /// // implementation goes here
287
+ /// }
288
+ ///
289
+ /// fn bar(&self) {
290
+ /// // let's not worry about implementing bar() for now
291
+ /// unimplemented!();
292
+ /// }
293
+ /// }
294
+ ///
295
+ /// fn main() {
296
+ /// let s = MyStruct;
297
+ /// s.foo();
298
+ ///
299
+ /// // we aren't even using bar() yet, so this is fine.
300
+ /// }
301
+ /// ```
257
302
#[ macro_export]
258
303
#[ unstable( feature = "core" ,
259
304
reason = "relationship with panic is unclear" ) ]
You can’t perform that action at this time.
0 commit comments