@@ -556,13 +556,15 @@ macro_rules! unreachable {
556556 } ) ;
557557}
558558
559- /// Indicates unfinished code by panicking with a message of "not yet implemented".
559+ /// Indicates unimplemented code by panicking with a message of "not implemented".
560560///
561561/// This allows the your code to type-check, which is useful if you are prototyping or
562562/// implementing a trait that requires multiple methods which you don't plan of using all of.
563563///
564- /// There is no difference between `unimplemented!` and `todo!` apart from the
565- /// name.
564+ /// The difference between `unimplemented!` and [`todo!`](macro.todo.html) is that while `todo!`
565+ /// conveys an intent of implementing the functionality later and the message is "not yet
566+ /// implemented", `unimplemented!` makes no such claims. Its message is "not implemented".
567+ /// Also some IDEs will mark `todo!`s.
566568///
567569/// # Panics
568570///
@@ -573,7 +575,7 @@ macro_rules! unreachable {
573575///
574576/// # Examples
575577///
576- /// Here's an example of some in-progress code. We have a trait `Foo`:
578+ /// Say we have a trait `Foo`:
577579///
578580/// ```
579581/// trait Foo {
@@ -583,13 +585,13 @@ macro_rules! unreachable {
583585/// }
584586/// ```
585587///
586- /// We want to implement `Foo` for 'MyStruct', but so far we only know how to
587- /// implement the `bar()` function. `baz()` and `qux()` will still need to be defined
588+ /// We want to implement `Foo` for 'MyStruct', but for some reason it only makes sense
589+ /// to implement the `bar()` function. `baz()` and `qux()` will still need to be defined
588590/// in our implementation of `Foo`, but we can use `unimplemented!` in their definitions
589591/// to allow our code to compile.
590592///
591- /// In the meantime, we want to have our program stop running once these
592- /// unimplemented functions are reached.
593+ /// We still want to have our program stop running if the unimplemented methods are
594+ /// reached.
593595///
594596/// ```
595597/// # trait Foo {
@@ -605,19 +607,18 @@ macro_rules! unreachable {
605607/// }
606608///
607609/// fn baz(&self) {
608- /// // We aren't sure how to even start writing baz yet,
609- /// // so we have no logic here at all.
610- /// // This will display "thread 'main' panicked at 'not yet implemented'".
610+ /// // It makes no sense to `baz` a `MyStruct`, so we have no logic here
611+ /// // at all.
612+ /// // This will display "thread 'main' panicked at 'not implemented'".
611613/// unimplemented!();
612614/// }
613615///
614616/// fn qux(&self) -> Result<u64, ()> {
615- /// let n = self.bar();
616617/// // We have some logic here,
617- /// // so we can use unimplemented! to display what we have so far .
618+ /// // We can add a message to unimplemented! to display our omission .
618619/// // This will display:
619- /// // "thread 'main' panicked at 'not yet implemented: we need to divide by 2 '".
620- /// unimplemented!("we need to divide by {}", n );
620+ /// // "thread 'main' panicked at 'not implemented: MyStruct isn't quxable '".
621+ /// unimplemented!("MyStruct isn't quxable" );
621622/// }
622623/// }
623624///
@@ -629,17 +630,21 @@ macro_rules! unreachable {
629630#[ macro_export]
630631#[ stable( feature = "rust1" , since = "1.0.0" ) ]
631632macro_rules! unimplemented {
632- ( ) => ( panic!( "not yet implemented" ) ) ;
633- ( $( $arg: tt) +) => ( panic!( "not yet implemented: {}" , $crate:: format_args!( $( $arg) +) ) ) ;
633+ ( ) => ( panic!( "not implemented" ) ) ;
634+ ( $( $arg: tt) +) => ( panic!( "not implemented: {}" , $crate:: format_args!( $( $arg) +) ) ) ;
634635}
635636
636637/// Indicates unfinished code.
637638///
638639/// This can be useful if you are prototyping and are just looking to have your
639640/// code typecheck.
640641///
641- /// There is no difference between `unimplemented!` and `todo!` apart from the
642- /// name.
642+ /// The difference between [`unimplemented!`] and `todo!` is that while `todo!` conveys
643+ /// an intent of implementing the functionality later and the message is "not yet
644+ /// implemented", `unimplemented!` makes no such claims. Its message is "not implemented".
645+ /// Also some IDEs will mark `todo!`s.
646+ ///
647+ /// [`unimplemented!`]: macro.unimplemented.html
643648///
644649/// # Panics
645650///
@@ -682,7 +687,7 @@ macro_rules! unimplemented {
682687/// let s = MyStruct;
683688/// s.bar();
684689///
685- /// // we aren't even using baz() yet , so this is fine.
690+ /// // we aren't even using baz(), so this is fine.
686691/// }
687692/// ```
688693#[ macro_export]
0 commit comments