@@ -719,7 +719,8 @@ macro_rules! unreachable {
719719/// The difference between `unimplemented!` and [`todo!`] is that while `todo!`
720720/// conveys an intent of implementing the functionality later and the message is "not yet
721721/// implemented", `unimplemented!` makes no such claims. Its message is "not implemented".
722- /// Also some IDEs will mark `todo!`s.
722+ ///
723+ /// Also, some IDEs will mark `todo!`s.
723724///
724725/// # Panics
725726///
@@ -805,50 +806,63 @@ macro_rules! unimplemented {
805806/// The difference between [`unimplemented!`] and `todo!` is that while `todo!` conveys
806807/// an intent of implementing the functionality later and the message is "not yet
807808/// implemented", `unimplemented!` makes no such claims. Its message is "not implemented".
808- /// Also some IDEs will mark `todo!`s.
809+ ///
810+ /// Also, some IDEs will mark `todo!`s.
809811///
810812/// # Panics
811813///
812- /// This will always [`panic!`].
814+ /// This will always [`panic!`] because `todo!` is just a shorthand for `panic!` with a
815+ /// fixed, specific message.
816+ ///
817+ /// Like `panic!`, this macro has a second form for displaying custom values.
813818///
814819/// # Examples
815820///
816821/// Here's an example of some in-progress code. We have a trait `Foo`:
817822///
818823/// ```
819824/// trait Foo {
820- /// fn bar(&self);
825+ /// fn bar(&self) -> u8 ;
821826/// fn baz(&self);
827+ /// fn qux(&self) -> Result<u64, ()>;
822828/// }
823829/// ```
824830///
825831/// We want to implement `Foo` on one of our types, but we also want to work on
826832/// just `bar()` first. In order for our code to compile, we need to implement
827- /// `baz()`, so we can use `todo!`:
833+ /// `baz()` and `qux()` , so we can use `todo!`:
828834///
829835/// ```
830836/// # trait Foo {
831- /// # fn bar(&self);
837+ /// # fn bar(&self) -> u8 ;
832838/// # fn baz(&self);
839+ /// # fn qux(&self) -> Result<u64, ()>;
833840/// # }
834841/// struct MyStruct;
835842///
836843/// impl Foo for MyStruct {
837- /// fn bar(&self) {
838- /// // implementation goes here
844+ /// fn bar(&self) -> u8 {
845+ /// 1 + 1
839846/// }
840847///
841848/// fn baz(&self) {
842- /// // let 's not worry about implementing baz() for now
849+ /// // Let 's not worry about implementing baz() for now
843850/// todo!();
844851/// }
852+ ///
853+ /// fn qux(&self) -> Result<u64, ()> {
854+ /// // We can add a message to todo! to display our omission.
855+ /// // This will display:
856+ /// // "thread 'main' panicked at 'not yet implemented: MyStruct is not yet quxable'".
857+ /// todo!("MyStruct is not yet quxable");
858+ /// }
845859/// }
846860///
847861/// fn main() {
848862/// let s = MyStruct;
849863/// s.bar();
850864///
851- /// // we aren't even using baz(), so this is fine.
865+ /// // We aren't even using baz() or qux (), so this is fine.
852866/// }
853867/// ```
854868#[ macro_export]
0 commit comments