Skip to content

Commit f9b0d61

Browse files
author
Zibi Braniecki
committed
Minor readability improvement to docs
1 parent a01baf4 commit f9b0d61

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

fluent-bundle/src/lib.rs

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,33 @@
1414
//! use fluent_bundle::{FluentBundle, FluentValue, FluentResource};
1515
//! use std::collections::HashMap;
1616
//!
17-
//! let res = FluentResource::try_new("
17+
//! let ftl_string = String::from("
1818
//! hello-world = Hello, world!
1919
//! intro = Welcome, { $name }.
20-
//! ".to_owned()).expect("Failed to parse FTL.");
20+
//! ");
21+
//! let res = FluentResource::try_new(ftl_string)
22+
//! .expect("Could not parse an FTL string.");
2123
//!
2224
//! let mut bundle = FluentBundle::new(&["en-US"]);
2325
//!
24-
//! bundle.add_resource(&res).expect("Failed to add FluentResource to Bundle.");
26+
//! bundle
27+
//! .add_resource(&res)
28+
//! .expect("Failed to add FTL resources to the bundle.");
2529
//!
26-
//! let value = bundle.format("hello-world", None);
27-
//! assert_eq!(value, Some(("Hello, world!".to_string(), vec![])));
30+
//! let (value, _) = bundle
31+
//! .format("hello-world", None);
32+
//! .expect("Failed to format a message.");
33+
//!
34+
//! assert_eq!(&value, "Hello, world!");
2835
//!
2936
//! let mut args = HashMap::new();
3037
//! args.insert("name", FluentValue::from("John"));
3138
//!
32-
//! let value = bundle.format("intro", Some(&args));
33-
//! assert_eq!(value, Some(("Welcome, John.".to_string(), vec![])));
39+
//! let (value, _) = bundle
40+
//! .format("intro", Some(&args));
41+
//! .expect("Failed to format a message.");
42+
//!
43+
//! assert_eq!(value, "Welcome, John.");
3444
//! ```
3545
3646
#[macro_use]

0 commit comments

Comments
 (0)