Skip to content

Commit 762bc1d

Browse files
refactor: Update examples to use .parse() instead of from_str
Switched example code in README and lib.rs documentation to use Rust's standard FromStr::parse() method instead of explicit from_str functions. This prepares for upcoming Bolt11Invoice FFI implementation and makes the examples more idiomatic.
1 parent 5abb42f commit 762bc1d

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,15 @@ fn main() {
3535

3636
// .. fund address ..
3737

38-
let node_id = PublicKey::from_str("NODE_ID").unwrap();
39-
let node_addr = SocketAddress::from_str("IP_ADDR:PORT").unwrap();
38+
let node_id = "NODE_ID".parse().unwrap();
39+
let node_addr = "IP_ADDR:PORT".parse().unwrap();
4040
node.open_channel(node_id, node_addr, 10000, None, None).unwrap();
4141

4242
let event = node.wait_next_event();
4343
println!("EVENT: {:?}", event);
4444
node.event_handled();
4545

46-
let invoice = Bolt11Invoice::from_str("INVOICE_STR").unwrap();
46+
let invoice = "INVOICE_STR".parse().unwrap();
4747
node.bolt11_payment().send(&invoice, None).unwrap();
4848

4949
node.stop().unwrap();

src/lib.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
//!
2525
//! ```no_run
2626
//! use ldk_node::Builder;
27-
//! use ldk_node::lightning_invoice::Bolt11Invoice;
2827
//! use ldk_node::lightning::ln::msgs::SocketAddress;
2928
//! use ldk_node::bitcoin::Network;
3029
//! use ldk_node::bitcoin::secp256k1::PublicKey;
@@ -44,15 +43,15 @@
4443
//!
4544
//! // .. fund address ..
4645
//!
47-
//! let node_id = PublicKey::from_str("NODE_ID").unwrap();
48-
//! let node_addr = SocketAddress::from_str("IP_ADDR:PORT").unwrap();
46+
//! let node_id = "NODE_ID".parse().unwrap();
47+
//! let node_addr = "IP_ADDR:PORT".parse().unwrap();
4948
//! node.open_channel(node_id, node_addr, 10000, None, None).unwrap();
5049
//!
5150
//! let event = node.wait_next_event();
5251
//! println!("EVENT: {:?}", event);
5352
//! node.event_handled();
5453
//!
55-
//! let invoice = Bolt11Invoice::from_str("INVOICE_STR").unwrap();
54+
//! let invoice = "INVOICE_STR".parse().unwrap();
5655
//! node.bolt11_payment().send(&invoice, None).unwrap();
5756
//!
5857
//! node.stop().unwrap();

0 commit comments

Comments
 (0)