@@ -557,13 +557,15 @@ macro_rules! unreachable {
557557 } ) ;
558558}
559559
560- /// Indicates unfinished code by panicking with a message of "not yet implemented".
560+ /// Indicates unimplemented code by panicking with a message of "not implemented".
561561///
562562/// This allows the your code to type-check, which is useful if you are prototyping or
563563/// implementing a trait that requires multiple methods which you don't plan of using all of.
564564///
565- /// There is no difference between `unimplemented!` and `todo!` apart from the
566- /// name.
565+ /// The difference between `unimplemented!` and [`todo!`](macro.todo.html) is that while `todo!`
566+ /// conveys an intent of implementing the functionality later and the message is "not yet
567+ /// implemented", `unimplemented!` makes no such claims. Its message is "not implemented".
568+ /// Also some IDEs will mark `todo!`s.
567569///
568570/// # Panics
569571///
@@ -574,7 +576,7 @@ macro_rules! unreachable {
574576///
575577/// # Examples
576578///
577- /// Here's an example of some in-progress code. We have a trait `Foo`:
579+ /// Say we have a trait `Foo`:
578580///
579581/// ```
580582/// trait Foo {
@@ -584,13 +586,13 @@ macro_rules! unreachable {
584586/// }
585587/// ```
586588///
587- /// We want to implement `Foo` for 'MyStruct', but so far we only know how to
588- /// implement the `bar()` function. `baz()` and `qux()` will still need to be defined
589+ /// We want to implement `Foo` for 'MyStruct', but for some reason it only makes sense
590+ /// to implement the `bar()` function. `baz()` and `qux()` will still need to be defined
589591/// in our implementation of `Foo`, but we can use `unimplemented!` in their definitions
590592/// to allow our code to compile.
591593///
592- /// In the meantime, we want to have our program stop running once these
593- /// unimplemented functions are reached.
594+ /// We still want to have our program stop running if the unimplemented methods are
595+ /// reached.
594596///
595597/// ```
596598/// # trait Foo {
@@ -606,19 +608,18 @@ macro_rules! unreachable {
606608/// }
607609///
608610/// fn baz(&self) {
609- /// // We aren't sure how to even start writing baz yet,
610- /// // so we have no logic here at all.
611- /// // This will display "thread 'main' panicked at 'not yet implemented'".
611+ /// // It makes no sense to `baz` a `MyStruct`, so we have no logic here
612+ /// // at all.
613+ /// // This will display "thread 'main' panicked at 'not implemented'".
612614/// unimplemented!();
613615/// }
614616///
615617/// fn qux(&self) -> Result<u64, ()> {
616- /// let n = self.bar();
617618/// // We have some logic here,
618- /// // so we can use unimplemented! to display what we have so far .
619+ /// // We can add a message to unimplemented! to display our omission .
619620/// // This will display:
620- /// // "thread 'main' panicked at 'not yet implemented: we need to divide by 2 '".
621- /// unimplemented!("we need to divide by {}", n );
621+ /// // "thread 'main' panicked at 'not implemented: MyStruct isn't quxable '".
622+ /// unimplemented!("MyStruct isn't quxable" );
622623/// }
623624/// }
624625///
@@ -630,17 +631,21 @@ macro_rules! unreachable {
630631#[ macro_export]
631632#[ stable( feature = "rust1" , since = "1.0.0" ) ]
632633macro_rules! unimplemented {
633- ( ) => ( panic!( "not yet implemented" ) ) ;
634- ( $( $arg: tt) +) => ( panic!( "not yet implemented: {}" , $crate:: format_args!( $( $arg) +) ) ) ;
634+ ( ) => ( panic!( "not implemented" ) ) ;
635+ ( $( $arg: tt) +) => ( panic!( "not implemented: {}" , $crate:: format_args!( $( $arg) +) ) ) ;
635636}
636637
637638/// Indicates unfinished code.
638639///
639640/// This can be useful if you are prototyping and are just looking to have your
640641/// code typecheck.
641642///
642- /// There is no difference between `unimplemented!` and `todo!` apart from the
643- /// name.
643+ /// The difference between [`unimplemented!`] and `todo!` is that while `todo!` conveys
644+ /// an intent of implementing the functionality later and the message is "not yet
645+ /// implemented", `unimplemented!` makes no such claims. Its message is "not implemented".
646+ /// Also some IDEs will mark `todo!`s.
647+ ///
648+ /// [`unimplemented!`]: macro.unimplemented.html
644649///
645650/// # Panics
646651///
@@ -683,7 +688,7 @@ macro_rules! unimplemented {
683688/// let s = MyStruct;
684689/// s.bar();
685690///
686- /// // we aren't even using baz() yet , so this is fine.
691+ /// // we aren't even using baz(), so this is fine.
687692/// }
688693/// ```
689694#[ macro_export]
0 commit comments