Skip to content

Commit 4a431f8

Browse files
authored
Merge pull request #18 from stappersg/libRSexample
Working example for lib.rs
2 parents a6dc2f6 + f7b046d commit 4a431f8

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

src/lib.rs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,35 @@
44
//!
55
//! ```rust,ignore # for some reason this crashes compiler
66
//! extern crate quire;
7-
//! #[macor_use] extern crate serde_derive;
7+
//! #[macro_use] extern crate serde_derive;
88
//! use quire::{parse_config, Options};
99
//! use quire::validate::{Structure, Scalar};
1010
//!
1111
//! #[derive(Deserialize)]
12+
//! #[allow(dead_code)]
1213
//! struct Config {
1314
//! item1: String,
1415
//! item2: Option<String>,
1516
//! }
1617
//!
17-
//! fn validator<'static>() -> Structure<'static> {
18+
//! fn validator() -> Structure<'static> {
1819
//! Structure::new()
1920
//! .member("item1", Scalar::new())
2021
//! .member("item2", Scalar::new().optional())
2122
//! }
2223
//!
23-
//! let cfg: Config;
24-
//! cfg = parse_config("config.yaml", &validator(), &Options::default())
25-
//! .expect("valid config");
24+
//! fn work(cfg: &Config) {
25+
//! println!("item1 is {}.", cfg.item1);
26+
//! //intln!("item2 is {}.", cfg.item2);
27+
//! // hey, this is just demonstration code ...
28+
//! }
2629
//!
30+
//! fn main() {
31+
//! let cfg: Config;
32+
//! cfg = parse_config("config.yaml", &validator(), &Options::default())
33+
//! .expect("valid config");
34+
//! work(&cfg)
35+
//! }
2736
//! ```
2837
//!
2938
#![warn(missing_debug_implementations)]

0 commit comments

Comments
 (0)