]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Fix compilation in `payment` rustdoc examples 2021-11-bad-rustdoc
authorMatt Corallo <git@bluematt.me>
Tue, 30 Nov 2021 21:01:39 +0000 (21:01 +0000)
committerMatt Corallo <git@bluematt.me>
Tue, 30 Nov 2021 22:54:28 +0000 (22:54 +0000)
The samples were not valid rust, but previous versions of rustc had
a bug where they were accepted anyway. Latest rustc beta no longer
accepts these.

lightning-invoice/src/payment.rs

index a141eb2c3e1445b3e3f08ce2afbd411989b32389..46bd86fb03ccef3a2169e37afe5558c27cc11afa 100644 (file)
@@ -63,7 +63,7 @@
 //! #     ) -> Result<(), PaymentSendFailure> { unimplemented!() }
 //! # }
 //! #
-//! # struct FakeRouter {};
+//! # struct FakeRouter {}
 //! # impl<S: Score> Router<S> for FakeRouter {
 //! #     fn find_route(
 //! #         &self, payer: &PublicKey, params: &RouteParameters, payment_hash: &PaymentHash,
@@ -71,7 +71,7 @@
 //! #     ) -> Result<Route, LightningError> { unimplemented!() }
 //! # }
 //! #
-//! # struct FakeScorer {};
+//! # struct FakeScorer {}
 //! # impl Writeable for FakeScorer {
 //! #     fn write<W: Writer>(&self, w: &mut W) -> Result<(), std::io::Error> { unimplemented!(); }
 //! # }
@@ -82,7 +82,7 @@
 //! #     fn payment_path_failed(&mut self, _path: &[&RouteHop], _short_channel_id: u64) {}
 //! # }
 //! #
-//! # struct FakeLogger {};
+//! # struct FakeLogger {}
 //! # impl Logger for FakeLogger {
 //! #     fn log(&self, record: &Record) { unimplemented!() }
 //! # }
 //! let invoice_payer = InvoicePayer::new(&payer, router, &scorer, &logger, event_handler, RetryAttempts(2));
 //!
 //! let invoice = "...";
-//! let invoice = invoice.parse::<Invoice>().unwrap();
-//! invoice_payer.pay_invoice(&invoice).unwrap();
+//! if let Ok(invoice) = invoice.parse::<Invoice>() {
+//!     invoice_payer.pay_invoice(&invoice).unwrap();
 //!
 //! # let event_provider = FakeEventProvider {};
-//! loop {
-//!     event_provider.process_pending_events(&invoice_payer);
+//!     loop {
+//!         event_provider.process_pending_events(&invoice_payer);
+//!     }
 //! }
 //! # }
 //! ```