|
14 | 14 | //! use fluent_bundle::{FluentBundle, FluentValue, FluentResource};
|
15 | 15 | //! use std::collections::HashMap;
|
16 | 16 | //!
|
17 |
| -//! let res = FluentResource::try_new(" |
| 17 | +//! let ftl_string = String::from(" |
18 | 18 | //! hello-world = Hello, world!
|
19 | 19 | //! 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."); |
21 | 23 | //!
|
22 | 24 | //! let mut bundle = FluentBundle::new(&["en-US"]);
|
23 | 25 | //!
|
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."); |
25 | 29 | //!
|
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!"); |
28 | 35 | //!
|
29 | 36 | //! let mut args = HashMap::new();
|
30 | 37 | //! args.insert("name", FluentValue::from("John"));
|
31 | 38 | //!
|
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."); |
34 | 44 | //! ```
|
35 | 45 |
|
36 | 46 | #[macro_use]
|
|
0 commit comments