codegen_rs/
lib.rs

1#![deny(missing_debug_implementations, missing_docs)]
2#![doc(html_root_url = "https://docs.rs/codegen-rs/0.1.4")]
3#![warn(rust_2018_idioms, clippy::nursery)]
4
5//! Provides a builder API for generating Rust code.
6//!
7//! The general strategy for using the crate is as follows:
8//!
9//! 1. Create a `Scope` instance.
10//! 2. Use the builder API to add elements to the scope.
11//! 3. Call `Scope::to_string()` to get the generated code.
12//!
13//! For example:
14//!
15//! ```rust
16//! use codegen_rs::Scope;
17//!
18//! let mut scope = Scope::new();
19//!
20//! scope.new_struct("Foo")
21//!     .derive("Debug")
22//!     .field("one", "usize")
23//!     .field("two", "String");
24//!
25//! println!("{}", scope.to_string());
26//! ```
27
28mod associated_type;
29mod block;
30mod body;
31mod bound;
32mod docs;
33mod field;
34mod fields;
35mod formatter;
36mod function;
37mod import;
38mod item;
39mod module;
40mod scope;
41mod type_def;
42mod variant;
43
44mod r#enum;
45mod r#impl;
46mod r#struct;
47mod r#trait;
48mod r#type;
49
50pub use associated_type::*;
51pub use block::*;
52pub use field::*;
53pub use formatter::*;
54pub use function::*;
55pub use import::*;
56pub use module::*;
57pub use scope::*;
58pub use variant::*;
59
60pub use r#enum::*;
61pub use r#impl::*;
62pub use r#struct::*;
63pub use r#trait::*;
64pub use r#type::*;